How to create a dataloader with variable-size input

You can just implement a custom batch sampler which ensures that only batches with same input size are created. Look here