Hi,
Yes this is an annoying limit of the inplace detection.
Going around the version counter is the only case where we still have to use .data. Unfortunately, .data has also the other effect of detaching the Tensor and so no gradient will be able to flow back through that computation.
The only way around that I can see is to wrap it into a custom Function. Where you use .data in the forward to hide the version changes.
But that means you have to write a custom backward for that 
Note that a cleaner API to stop sharing version while preserving the autograd is in our todo list for the .data deprecation task here: https://github.com/pytorch/pytorch/issues/30987 8
But we didn’t had time to get around to do it yet.