Given a 3D array such as:
array = np.random.randint(1, 6, (3, 3, 3))
and an array of maximum values across axis 0:
max_array = array.max(axis=0)
Is there a vectorised way to count the number of elements in axis 0 of array which are equal to the value of the matching index in max_array? For example, if array contains [1, 3, 3] in one axis 0 position, the output is 2, and so on for the other 8 positions, returning an array with the counts.