Pytorch RuntimeError: stack expects each tensor to be equal size

I assume your custom collate function should work. What kind of error message are you seeing using it?