I am trying to create batches for my training. my inputs are tensors with varying dimension.
Let’s say I have a list of tensors for source (input) and target (output).
tensors in the source are of varying dimension. For example: torch.Size([1, 100]), torch.Size([2, 100]), torch.Size([3, 100]), torch.Size([4, 100])
but tensors in target are all torch.Size([1, 100])
I want to have batches with the same dimensions. like all the [1,100] be batched together. all [2,100] batched together. and consequently I want to have the corresponding target tensors paired with source tensors.
Can anyone help me or point me to the right direction? Many thanks
Note: The thing is dim(0) which is  varying here can be considered similar to sequence length when we do normal language modeling or seq2seq.