How to calculate gradient w.r.t the specific input element?

for instance, I’ve a input tensor matrix is (4,2).
I want to obtain gradient w.r.t the input element (1,1), and all of other element’s gradient is 0.
because I want to know how each element changing the output independent.

You can do backprop normally, then index onto the grad, e.g. inp.grad[1, 1]