Add tensor to another by repeating along axis
I have a tensor out with shape:

torch.Size([4, 644, 25])


and another one x with shape:

torch.Size([4, 161, 25])


I want to add x to out 4 times, something like:

        out[:, 0:161] += x
        out[:, 161:322] += x
        out[:, 322:483] += x
        out[:, 483:644] += x


Is there some one-liner that I can use to do this?

We can use np.tile here:

out += np.tile(x, (1,out.shape[1]//x.shape[1],1))


Or using pytorch's repeat:

out += x.repeat(1,out.shape[1]//x.shape[1],1)

