torch.no_grad will disable gradient calculation, so that all operations in this block won’t be tracked by Autograd.
Using the underlying .data attribute will most likely work in this case.
However, I consider it dangerous, as it might silently introduce errors in the gradient calculations.