I’ve found the solution, all you need to do is to implement a custom function called:
collate_fn
It takes a batch (list) of examples returned by the Dataset getitem() function, and should return a batch as desired by the network (or next consumer).