Here is the which I am getting wrt the I have mentioned above:
Epoch 1 | Loss: 5.17788553238 | Train PPL: 177.307510376 | Val PPL: 129.847122192

Model trained.
('string is', "but while the new york stock exchange did n't fall")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-21-6c5c0b136b8a> in <module>()
      3     model.cuda()
      4 trainer = Trainer(train_iter = train_iter, val_iter = val_iter)
----> 5 trainer.train_model(model = model, num_epochs = 1)

<ipython-input-20-d6fd9f7bb41a> in train_model(self, model, num_epochs)
     63 
     64         print('Model trained.')
---> 65         self.write_kaggle(model)
     66         print('Output saved.')
     67 

<ipython-input-20-d6fd9f7bb41a> in write_kaggle(self, model, input_file)
     93     def write_kaggle(self, model, input_file = '../data/input.txt'):
     94         inputs = open(input_file, 'r').read().splitlines()
---> 95         outputs = [self.predict_sentence(sentence, model) for sentence in inputs]
     96         with open('lstm_output.txt', 'w') as f:
     97             f.write('id,word')

<ipython-input-20-d6fd9f7bb41a> in predict_sentence(self, string, model, TEXT)
     85         hidden = model.init_hidden()
     86         x = self.string_to_batch(string)
---> 87         logits, _ = model.forward(x, hidden, train = False)
     88         argsort_ids = np.argsort(logits[-1].data.tolist())
     89         out_ids = argsort_ids[-20:][::-1]

<ipython-input-19-70af3154bb0b> in forward(self, x, hidden, train)
     33         embedded = self.drop(embedded) if train else embedded
     34 
---> 35         lstm_output, hdn = self.lstm(embedded, hidden)
     36         reshaped = lstm_output.view(-1, lstm_output.size(2))
     37         dropped = self.drop(reshaped) if train else reshaped

/home/naditya/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.pyc in __call__(self, *input, **kwargs)
    489             result = self._slow_forward(*input, **kwargs)
    490         else:
--> 491             result = self.forward(*input, **kwargs)
    492         for hook in self._forward_hooks.values():
    493             hook_result = hook(self, input, result)

/home/naditya/anaconda2/lib/python2.7/site-packages/torch/nn/modules/rnn.pyc in forward(self, input, hx)
    176             flat_weight = None
    177 
--> 178         self.check_forward_args(input, hx, batch_sizes)
    179         func = self._backend.RNN(
    180             self.mode,

/home/naditya/anaconda2/lib/python2.7/site-packages/torch/nn/modules/rnn.pyc in check_forward_args(self, input, hidden, batch_sizes)
    124             raise RuntimeError(
    125                 'input must have {} dimensions, got {}'.format(
--> 126                     expected_input_dim, input.dim()))
    127         if self.input_size != input.size(-1):
    128             raise RuntimeError(

RuntimeError: input must have 3 dimensions, got 2