Thomas,
Thank you for the detailed answer. I think I understand what’s going on in the provided code, but I fail to see how this addresses my issue.
To give more details, just as your artificial input here is 32000 samples of 100 dimensions each, in my problem let’s say I also have 32000 samples, but the dimensions vary. A data point might have 35 features, another might have 80 etc.
The code you posted, by default has batches of equal length, since they all are 100-D. However, I want to do the same in my case, where the sizes are not the same as displayed above. Therefore, what I wish is to find a way to group batches of equal/similar lengths together when passed to the model.
If for example my batch size is 4, I want each 4 samples to be as close as possible in terms of length. I do not wish, for instance, to have a batch where the 4 files have the following input sizes: 80, 20, 35, 10. Instead, I want something like this: 80, 75, 82, 90 (this is just an example).
Unless of course, you mean that I should first sort my data from longest to shortest (or in any case, arrange them as I wish)  and then do the ‘batch_size=None’ DataLoader?
If so, forgive me for not understanding earlier.
Thanks again for your responses!