I was reading the documentation and I came across the following sentence:
- is any number of trailing dimensions, including none.
what is the meaning of “trailing dimensions”? May I also get an example to clarify the point?
for context:
Packs a Tensor containing padded sequences of variable length.
inputcan be of sizeT x B x *where T is the length of the longest sequence (equal tolengths[0]),Bis the batch size, and*is any number of dimensions (including 0). Ifbatch_firstisTrue,B x T x *inputis expected.For unsorted sequences, use enforce_sorted = False. If
enforce_sortedisTrue, the sequences should be sorted by length in a decreasing order, i.e.input[:,0]should be the longest sequence, andinput[:,B-1]the shortest one. enforce_sorted = True is only necessary for ONNX export.
I actually meant to ask about pad_sequence torch.nn — PyTorch 2.1 documentation