Solved by InnovArul in post #2 
              
              
                yes, you could do that. 
try 
input.requires_grad = True

and after the loss.backward() call, you can access the gradients w.r.t input by x.grad.