Ragged tensors for list of variable shape 2D tensors in PyTorch in order to be able to feed data of variable shape in a batch size > 1

I have a list of 2D tensors in which the first dimension is varied while the second dimension is not varied.

I came across ragged tensor concept and searching for equivalents came across this answer by @ptrblck for 1D tensors of different shape.

How can I extend this to a nested list of 2D tensors?
Please consider I have a batch size of 4 and my tensors are of these sizes:
[ 300x512, 1000x512, 11x512, 8000x512]

Is this what you would do when you have different sized tensors in a batch? Because when I don’t have the same size tensors, I get error and vision transformer requires me to have all of my intermediate representation of the same dimension.