A = [np.array([i, j], dtype=np.int64) for i in range(1, data.shape[0] - 1) for
    j in range(1, data.shape[1] - 1) if all((data[i - 1:i + 2, j - 1:j + 2] ==
    data[i, j]).flatten())]
Retrieve position of elements with setting some criteria in numpy