with open(args.outf, "w") as outf:
for i in range(args.words):
output, hidden = learner.module_(input, hidden)
word_weights = output.squeeze().data.div(args.temperature).exp().cpu()
word_idx = torch.multinomial(word_weights, 1)[0]
input.data.fill_(word_idx)
word = corpus.dictionary.idx2word[word_idx]
outf.write(word + ("\n" if i % 20 == 19 else " "))