I suggest you to go through the following github tutorial by HarshTrivedi 27, Tushar-N 13. This tutorial gives detailed explaination of how to use pack_padded_sequence and pad_packed_sequence with RNN arachitectures. pack_padded_sequence give you two things, one is the single array contain embedding of all sequence of all words and second is the length of batch sizes which can be used to determine number of characters in one word. Once you go throgh above links, I think your doubts will be clear about how to handle variable length in your own implementation.