Refer to the FAQ in PyTorch regarding using total lengths. There’s a subtlety in using the pack_padded_sequence and pad_packed_sequence utility functions with DataParallel.
https://pytorch.org/docs/stable/notes/faq.html 547