Pytorch index out of range (no cuda)

I am a first time user trying to use PyTorch 0.4.0 (installed using anaconda in my custom environment that uses python 3.6 among other things) to generate text. I am running the code found in the GitHub location pytorch/examples/word_language_model by training it on a really small data set (the children’s book Telegraph Boy). I am running it locally on my Mac which does not have an NVIDIA GPU. The command I use is:

python main.py --data <location of data containing test, valid and train files> --epochs 10 --tied

This works fine. When trying to generate new text however (using >> python generate.py), I get an error as below…what is wrong?

Traceback (most recent call last):
File “generate.py”, line 59, in
output, hidden = model(input, hidden)
File “/anaconda3/envs/ML_env/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 491, in call
result = self.forward(*input, **kwargs)
File “/Users/tararengarajan/Documents/Github/examples/word_language_model/model.py”, line 45, in forward
emb = self.drop(self.encoder(input))
File “/anaconda3/envs/ML_env/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 491, in call
result = self.forward(*input, **kwargs)
File “/anaconda3/envs/ML_env/lib/python3.6/site-packages/torch/nn/modules/sparse.py”, line 108, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File “/anaconda3/envs/ML_env/lib/python3.6/site-packages/torch/nn/functional.py”, line 1076, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: index out of range at /Users/soumith/minicondabuild3/conda-bld/pytorch_1524590658547/work/aten/src/TH/generic/THTensorMath.c:343