torch.autograd.grad(output, x)
torch.autograd.grad(x, output)

both do not work either. Am I making a silly mistake? I expect this to return a tensor of all the d_output/dx (I just realized I typed it wrong in my initial problem description). I want the partial derivatives of all the outputs with respect to the one input.