There is a scatter function in pytorch
http://pytorch.org/docs/master/tensors.html#torch.Tensor.scatter_ 593
I’m not 100% sure about how the autograd mechanics work during assignment yet. But from my understanding when you create a new tensor using .data it loses the history of the variable. Hence why no backprop would occur.