In that case I would focus on the error (about the unused variable) by reverting the changes and make sure your model still trains.
I assume the error you mentioned claims that no parameters were found which require gradients during the backward pass.
If so, it’s usually a sign, that all parameters were frozen or that the computation graph was detached at some point.