I pulled out the code from the encode function which has model.forward(). I think this can be used to get the Variable and backpropagate the error to update the parameters.
sentences, lengths, idx_sort = model.prepare_samples(lstSentences, bsize=128, tokenize=True, verbose=True)
batch = Variable(model.get_batch(sentences))

In the encode and visualize function of the original model file 1 they always use volatile=False while extracting the batch variable. However, in this case, we need not set it to True. However, I get a memory error the moment I do this,
if model.is_cuda():
    batch = batch.cuda()
embeddingsTxtVar = model.forward((batch, lengths))


RuntimeError                              Traceback (most recent call last)
<ipython-input-13-76f33c27e0af> in <module>()
      1 if model.is_cuda():
      2     batch = batch.cuda()
----> 3 embeddingsTxtVar = model.forward((batch, lengths))

~/notebooks/code/InferSent/encoder/models.py in forward(self, sent_tuple)
     51         # Handling padding in Recurrent Networks
     52         sent_packed = nn.utils.rnn.pack_padded_sequence(sent, sent_len)
---> 53         sent_output = self.enc_lstm(sent_packed)[0]  # seqlen x batch x 2*nhid
     54         sent_output = nn.utils.rnn.pad_packed_sequence(sent_output)[0]
     55 

/anaconda/envs/py35/lib/python3.5/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    222         for hook in self._forward_pre_hooks.values():
    223             hook(self, input)
--> 224         result = self.forward(*input, **kwargs)
    225         for hook in self._forward_hooks.values():
    226             hook_result = hook(self, input, result)

/anaconda/envs/py35/lib/python3.5/site-packages/torch/nn/modules/rnn.py in forward(self, input, hx)
    160             flat_weight=flat_weight
    161         )
--> 162         output, hidden = func(input, self.all_weights, hx)
    163         if is_packed:
    164             output = PackedSequence(output, batch_sizes)

/anaconda/envs/py35/lib/python3.5/site-packages/torch/nn/_functions/rnn.py in forward(input, *fargs, **fkwargs)
    349         else:
    350             func = AutogradRNN(*args, **kwargs)
--> 351         return func(input, *fargs, **fkwargs)
    352 
    353     return forward

/anaconda/envs/py35/lib/python3.5/site-packages/torch/autograd/function.py in _do_forward(self, *input)
    282         self._nested_input = input
    283         flat_input = tuple(_iter_variables(input))
--> 284         flat_output = super(NestedIOFunction, self)._do_forward(*flat_input)
    285         nested_output = self._nested_output
    286         nested_variables = _unflatten(flat_output, self._nested_output)

/anaconda/envs/py35/lib/python3.5/site-packages/torch/autograd/function.py in forward(self, *args)
    304     def forward(self, *args):
    305         nested_tensors = _map_variable_tensor(self._nested_input)
--> 306         result = self.forward_extended(*nested_tensors)
    307         del self._nested_input
    308         self._nested_output = result

/anaconda/envs/py35/lib/python3.5/site-packages/torch/nn/_functions/rnn.py in forward_extended(self, input, weight, hx)
    291             hy = tuple(h.new() for h in hx)
    292 
--> 293         cudnn.rnn.forward(self, input, hx, weight, output, hy)
    294 
    295         self.save_for_backward(input, hx, weight, output)

/anaconda/envs/py35/lib/python3.5/site-packages/torch/backends/cudnn/rnn.py in forward(fn, input, hx, weight, output, hy)
    289                 ctypes.byref(reserve_size)
    290             ))
--> 291             fn.reserve = torch.cuda.ByteTensor(reserve_size.value)
    292 
    293             check_error(lib.cudnnRNNForwardTraining(

RuntimeError: cuda runtime error (2) : out of memory at /opt/conda/conda-bld/pytorch_1503963423183/work/torch/lib/THC/generic/THCStorage.cu:66

I get the same error when I explicitly put volatile=False or requires_grad=True or both as an additional argument/parameter to
batch = Variable(model.get_batch(sentences), 'either or both additional parameter as above')
Any idea about what I maybe doing wrong here? Please excuse me, I am very new to PyTorch.