Thanks for the reply. Actually, I have a tensor like (B,C,H,W) and I want to multiply the last two dimensions with a gaussian (H and W are the spatial dimensions. So it’s like an attention on the middle pixels). I want it to be fully implemented in Pytorch to be able to do backpropagation.