Isn’t it the same as if you just summed up a along that dimension and then added it to each element of b?
import torch
from torch.autograd import Variable
import numpy as np
import torch.nn as nn

a = Variable(torch.Tensor(3, 5).normal_(), requires_grad=True)
b = Variable(torch.Tensor(3, 5).normal_(), requires_grad=True)

a_summed = a.sum(0) # sum along first dimension
result = b + a_summed.expand_as(b)
result.backward(torch.randn(5, 3))