Difference between eval(), torch.no_grad() and with torch.set_grad_enabled()

i understood that

  • eval() changes the bn and dropout layer’s behaviour
  • torch.no_grad() deals with the autograd engine and stops it from calculating the gradients, which is not compulsory but the recommended way of doing validation

BUT, I didn’t understand the use of with torch.set_grad_enabled()

Can somebody pls explain what is its use and where exactly can it be used.