Hi, suppose you like to calculate the hessian vector product of (∂^2f/∂x^2)v then,
>>> v = Variable(torch.Tensor([1, 1]))
>>> x = Variable(torch.Tensor([0.1, 0.1]), requires_grad=True)
>>> f = 3 * x[0] ** 2 + 4 * x[0] * x[1] + x[1] **2
>>> grad_f, = autograd.grad(f, x, create_graph=True)
>>> z = grad_f @ v
>>> z.backward()
>>> x.grad
Variable containing:
 10
  6
[torch.FloatTensor of size 2]

since (∂^2f/∂x^2)v=(∂/∂x){(∂f/∂x)v}