Do you mean backward of backward (second derivative)?
try loss.backward(create_graph=True)
see  https://github.com/pytorch/pytorch/pull/1016 35
x = Variable(torch.randn(2, 2), requires_grad=True)
x.mul(2).sum().backward(create_graph=True)
y = x.grad.mul(2).sum()
# This accumulates grad of grad into x.grad, adding together results of both backward() calls
y.backward()