Solved by soulitzer in post #2 
              
              
                Hi, 
If you are trying to compute the second order partial derivative, maybe something like: 
import torch

x = torch.tensor(2., requires_grad=True)
y = torch.tensor(3., requires_grad=True)

def f(a, b):
  return a**2 * b

def df_da(a, b):
  return torch.autograd.grad(f(a, b), (a,), create_graph=Tru…