@hanhvn I see the problem. You could pad your inputs to have always the same number of images. Meaning extending the number of images with zero filled images to (max_img, 1, max_neg_img). This could be done with a custom transform 4 to pad for max image count in the whole dataset or the collate_fn 19 for batch level padding.
With padding you need to make sure to mask your values to ignore the zeros in further processing.
Good luck and have fun with your implementation.