M = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
M = np.asarray(M)
N = np.zeros(M.shape)
for i in range(M.shape[0]):
    for j in range(M.shape[1]):
        N[i][j] = sumNeighbors(M, i, j)
print('Original matrix:\n', M)
print('Summed neighbors matrix:\n', N)
Самый простой способ вернуть сумму соседей матрицы в numpy