I’m not sure what your code is exactly doing, but I think the addition is throwing this error:
a = np.random.randn(2, 3)
b = np.random.randn(2, 3, 4)

try:
    a + b
except ValueError as e:
    print(e)

a[:, :, None] + b  # works

If you would like to broadcast x or y before the addition, just use the last line of code in my snippet.