def create_mask_from_window(x):
mask = x == np.max(x)
return mask
The function is to return the maximum mask in the matrix, the operation is very beautiful. Determine whether each value in the x matrix is equal to the maximum value one by one, whether it returns True, whether it returns False