Variables are deprecated since PyTorch 0.4 and the usage of the .data attribute is not recommended, will be removed in the future, and might yield side effects.
That being said, could you explain your use case a bit more and what you are trying to achieve?