Sorry, according to the source code on official website http://pytorch.org/docs/0.3.1/_modules/torch/nn/utils/rnn.html#pack_padded_sequence 49, I can’t find the code you provided, it seems like  pack_padded_sequence() use lengths as a list directly.