Hi,
The thing is that you should not use .data anymore. It is the old api and is really bugprone as you can see.
If the goal is to get a tensor with the same content but without the autograd graph, you should use .detach(). It will return a tensor with the same content and requires_grad=False.
If the goal is to make some changes on a tensor that are not tracked by the autograd, then you should do these ops within a with torch.no_grad(): block. It will allow you to do any op on a tensor as if it was not requirering any gradient and these ops will not be recorded by the autograd engine.