Thanks for your reply. Alternatively, since you said I can directly grab the gradient, I can also assign self.gradient in my code to the gradient of the input itself?
Also thanks a lot for your patience!