It seems that you are missing the following line in the loop (based on this tutorial 904):
# Also, we need to clear out the hidden state of the LSTM,
# detaching it from its history on the last instance.
model.hidden = model.init_hidden()