Toggle between multiple dataloaders during the training

Hi,
I have multiple dataloaders and I want to randomly select a batch from a dataloader randomly during the training.

For example, the first batch is from dataset 1 and the second batch is from dataset 2.
The batch size and the input image size is the same across all the dataloaders.

Please let me know if there is any possible example or method.

You could create iterators for each DataLoader and get the next batches via next(data_loader_iter) from the corresponding DataLoader. Using this approach you would need to make sure there are enough batches available or catch the StopIteration.