The thing is that torch.no_grad() is a convenient way to set the gradients and restore their state. But if something calls directly set_grad_enabled(True) 12, it will nullify the effect of your torch no_grad block 
That being said, this is quite unlikely. Did you checked if the output do require gradients? If they don’t this is not the problem.