Batching in DataLoader for Text Supervised Data

You could write a custom collate_fn, which will create the batches with the variable length data samples.
Have a look at this example.