torch.nn.utils.rnn.pad_packed_sequence
torch.nn.utils.rnn.pad_packed_sequence(sequence, batch_first=False, padding_value=0.0, total_length=None)
Pads a packed batch of variable length sequences.
It is an inverse operation to "pack_padded_sequence()".
The returned Tensor's data will be of size "T x B x ", where T
   is the length of the longest sequence and B is the batch size. If
   "batch_first" is True, the data will be transposed into "B x T x "
   format.
-[ Example ]-



from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
seq = torch.tensor([[1, 2, 0], [3, 0, 0], [4, 5, 6]])
lens = [2, 1, 3]
packed = pack_padded_sequence(seq, lens, batch_first=True, enforce_sorted=False)
packed
   PackedSequence(data=tensor([4, 1, 3, 5, 2, 6]), batch_sizes=tensor([3, 2, 1]),
                  sorted_indices=tensor([2, 0, 1]), unsorted_indices=tensor([1, 2, 0]))


