torch.no_grad() disables gradient calculation inside the body of the with statement (it acts just as an ordinary context manager, but it can be used as a decorator as well). Even if other functions are invoked inside the body, the operations defined by these functions will not be recorded by the autograd engine.