Просто используйте словарь:
{k: x1.get(k,0) + x2.get(k,0) for k in set(x1)}
Например:
import numpy as np
np.random.seed(0)
x1 = {k: np.random.randint(20, size=(2, 2)) for k in range(5)}
x2 = {k: np.random.randint(20, size=(2, 2)) for k in range(5)}
Выход:
{0: array([[12, 15],
[ 0, 3]]), 1: array([[ 3, 7],
[ 9, 19]]), 2: array([[18, 4],
[ 6, 12]]), 3: array([[ 1, 6],
[ 7, 14]]), 4: array([[17, 5],
[13, 8]])}
{0: array([[ 9, 19],
[16, 19]]), 1: array([[ 5, 15],
[15, 0]]), 2: array([[18, 3],
[17, 19]]), 3: array([[19, 19],
[14, 7]]), 4: array([[0, 1],
[9, 0]])}
Затем, применяя наше решение, мы получаем:
{0: array([[21, 34],
[16, 22]]), 1: array([[ 8, 22],
[24, 19]]), 2: array([[36, 7],
[23, 31]]), 3: array([[20, 25],
[21, 21]]), 4: array([[17, 6],
[22, 8]])}