Hi,
The problem is that advanced indexing like [[2, 4]] does not always return a view into the original Tensor. It sometimes returns a different Tensor. And so when you do tensor[[2, 4]].copy_(b.tensor), you actually do the copy into a Tensor that is completely independent of tensor.
For this to work, you can do tensor[[2, 4]] = b.tensor so that the advanced indexing will be used in “assignment mode” and pytorch will do the right thing.