Use different dataloaders in different epochs?

Hi, I am trying to train a model using different dataloaders in different epochs. The main purpose of doing this (instead of simply concat different datasets) is that I am interested in applying different collate_fn for different epochs, which cannot be done with simple data concatenation.

One possible dirty approach I think of is to use if else condition to manually switch between different dataloaders, something like:

if idx_epoch % 4 in (0, 1):
    # use dataloader A for training
elif idx_epoch % 4 in (2,3):
    # use dataloader B for training

I am wondering if anyone know better ways to do this?

Thank you!