You do your calculation in a no_grad block.
with torch.no_grad():
   ...

The opposite (e.g. you are inside a  torch.no_grad block and need gradients is with torch.enable_grad(): ....
Best regards
Thomas