When you perform training, to use teacher forcing, just shift expected values by one position and feed it back.
When you predict, you should store the hidden states of lstm, and feed them back position by position. nn.LSTM support this.
This sample might be helpftul: https://github.com/pytorch/examples/tree/master/word_language_model 494