Thank you! That worked well, but my training is really slow now, because of the additional loop and predicting every single value of x_train after another.
Another question regarding this issue is, where to put the loss.backward() call exactly. Should it be inside the additional loop over x_train, or outside? I am not really sure what difference it makes.
EDIT: I think I figured it out myself. I put it into the top level loop for each epoch and added another tensor storing the predictions in order to calculate the loss correctly over the all time steps.