What you describe is called NestedTensors 1 in PyTorch parlance and it isn’t there yet.
Until that materializes, the options are mostly padding (to regular shape) or packing. Either might be good to combine with “stratifying” your batches to have similar sizes, e.g. torchtext does this 1, I have done that before for CT scans.
Whether packing or batching is more appropriate and how the stratification is best done depends on your data and your task.
Best regards
Thomas