pytorch no grad code example Example: with torch.no_grad() if condition with torch.set_grad_enabled(not no_grad_condition): out=network(input)