Thanks, albanD.
I did the following:
inpt2_grad = grad(output, inpt2, create_graph=True, retain_graph=True)
But now I am encountering a new issue:
One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior.
Any insights of what allow_unused does? I tried to read the documentation, but I got lost.
Also, if I add the allow_unused=True statement, grad(output,…) returns None.