Hi,
You don’t actually need gradients for inputs here. All the parameters inside the model already require gradients and you don’t need to set it on inputs.
The goal is to disable the autograd when you’re not training to reduce the memory consumption (because it won’t build the computational graph and won’t save the necessary intermediary results).
So yes, you can remove it if you want, it will work as well, but it will use more memory.