arr = np.array([[[0, 0, 0, -1], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [
    -1, 0, 0, 0]], [[0, 0, 0, 0], [0, -1, 0, 0], [0, 0, 0, 0], [0, 0, 0, -1
    ], [0, 0, 0, 0]]])
local_minima_locations = detect_local_minima(arr)
How to find the local minima of a smooth multidimensional array in NumPy efficiently?