Autograd calculate the analytical derivative of NN

I wan’t to know if the torch.autograd.grad calculate the analytical gradient of NN output or just the eulerienne gradient

It calculates the analytical gradient by chain rule.

You can look at Overview of PyTorch Autograd Engine to get more details.