class_docstr: Iterate over datasets and provide a batch per dataset in each mini-batch.
class_docstr_tok: ["Iterate","over","datasets","and","provide","a","batch","per","dataset","in","each","mini-batch","."]
code: def __init__(
      self,
      datasets: Sequence[Sized],
      samplers: Sequence[BatchSampler],
      termination_dataset_idx: int = 0,
      oversample_small_datasets: bool = False,
      never_ending: bool = False,
  ):
      assert len(datasets) == len(samplers)
      assert never_ending or (
          termination_dataset_idx >= 0
          and termination_dataset_idx < len(datasets)
      )
  
      self.datasets = list(datasets)
      self.samplers = list(samplers)
      self.cumulative_sizes = ConcatDataset.cumsum(self.datasets)
      self.never_ending = never_ending
  
      if self.never_ending:
          self.termination_dataset_idx = -1
          self.termination_dataset_iterations = 10**10
          self.oversample_small_datasets = True
  
          if sum(len(x) for x in self.samplers) == 0:
              raise RuntimeError(
                  "The never ending sampler must able to create a mini-batch"
              )
      else:
          # termination_dataset_idx => dataset used to determine the epoch end
          self.termination_dataset_idx = termination_dataset_idx
          self.termination_dataset_iterations = len(
              self.samplers[self.termination_dataset_idx]
          )
  
          self.oversample_small_datasets = oversample_small_datasets
  
imports: from typing import Any, Dict, Iterator, List, Optional, Sequence, Sized, Union
  import numpy
  from torch.utils.data import DistributedSampler, Dataset
  from torch.utils.data.dataloader import DataLoader
  from avalanche.benchmarks.utils.data import AvalancheDataset
  from avalanche.benchmarks.utils.data_attribute import DataAttribute
  from avalanche.benchmarks.utils.ffcv_support.ffcv_components import HybridFfcvLoader, has_ffcv_support
  from avalanche.distributed.distributed_helper import DistributedHelper
  from torch.utils.data.sampler import Sampler, BatchSampler
  from torch.utils.data import ConcatDataset
label_desc: Use image node_id 1 to create a new MultiDatasetSampler object from inherited base classes: Sampler with example: obj = MultiDatasetSampler(datasets, samplers, termination_dataset_idx, oversample_small_datasets, never_ending)