You can create a custom collate_fn in your dataloader that pads or trims the output from the Dataset properly and then stacks the padded/trimmed tensors into a batch.  Or if you are using an rnn then you can put it into a PackedSequence 21.