Thanks for the update.
No, I don’t think you should detach() this tensor, since the computation graph will be cut at this place and no modules used before the detach() operation was used will get a valid gradient (self.classifier would be the only trained module).
The initial error (without using retain_graph=True) is raised e.g. if you try to calculate the gradients via a second backward() call while the intermediate forward activations were already freed in the first backward() operation.
This is often an issue in RNNs if you are e.g. reusing the hidden states without detaching these (the computation graph would grow in each iteration and the backward() operation would then try to calculate the gradients for the current and the previous iterations).
Given that, I think you should check, if using output, hidden = self.lstm(output, hidden.detach()) would work (and pass output directly to self.classifier again).