I would recommend to wrap evenrything in a with torch.no_grad() block, which should not be tracked by Autograd.
While this approach of manually setting requires_grad(True) will most likely work for this manual approach, it’s a bit clearer for me to just use torch.no_grad.