title: Combine multiple DataLoaders sequentially
body: <p>I'm interested in how I'd go about combining multiple <code>DataLoader</code>s sequentially for training. <em>I understand I can use <code>ConcatDataset</code> to combine datasets first</em>, but this does not work for my use case. I have a custom <code>collate_fn</code> that is passed to each dataloader, and this function depends on an attribute of the underlying <code>Dataset</code>. So, I'll have a set of custom <code>DataLoader</code>s like the following:</p>
  <pre class="lang-py prettyprint-override"><code>def custom_collate(sample, ref):
      data = clean_sample(torch.stack([x[0] for x in sample]), ref)
      labels = torch.tensor([x[1] for x in sample])
      return data, labels
  
  class CollateLoader(torch.utils.data.DataLoader):
      def __init__(self, ref, *args, **kwargs):
          collate_fn = functools.partial(custom_collate, ref=ref)
          super().__init__(collate_fn = collate_fn, *args, **kwargs)
  </code></pre>
  <p>Where <code>ref</code> is a property of the custom <code>Dataset</code> class and is passed on initialization of a <code>CollateLoader</code>. Also, I know transforms can be applied in the <code>Dataset</code>, but in my case it must be done batch-wise.</p>
  <p>So, how would I go about combining multiple <code>DataLoader</code>s? In the PyTorch-Lightning <code>LightningDataModule</code>, we can do something like</p>
  <pre><code>def train_dataloader(self):
      return [data_loader_1, data_loader_2]
  </code></pre>
  <p>But this will return a list of batches, not the batches sequentially.</p>