RNN backward can only be called in training mode, even if I just wanted to compute grdient w.r.t. inputs

Hello everybody,

I understand that we need to set RNN in training mode to optimize the weights of the neural network. However, in my case, I was trying to use torch.autograd.grad to compute the gradient w.r.t. the inputs. It still returned the same error.

embedded_grad = torch.autograd.grad(loss, embedding_temp)[0]

Is this normal or I have a bug in my code?

thanks!