class_docstr: Data loader that balances data from multiple datasets emitting an
  infinite stream.
class_docstr_tok: ["Data","loader","that","balances","data","from","multiple","datasets","emitting","an","infinite","stream","."]
docstr: Data loader that balances data from multiple datasets emitting an
  infinite stream.
  
  Mini-batches emitted by this dataloader are created by collating
  together mini-batches from each group. It may be used to balance data
  among classes, experiences, tasks, and so on.
  
  :param datasets: an instance of `AvalancheDataset`.
  :param batch_size: the size of the batch to take from each dataset.
      Please note that, differently from other Avalanche multi dataset
      loaders, this value is the per-dataset contribution to the
      final mini-batch, NOT the final mini-batch size. The final
      mini-batches will be of size `len(datasets) * batch_size`.
  :param distributed_sampling: If True, apply the PyTorch
      :class:`DistributedSampler`. Defaults to True.
      Note: the distributed sampler is not applied if not running
      a distributed training, even when True is passed.
  :param kwargs: data loader arguments used to instantiate the loader for
      each group separately. See pytorch :class:`DataLoader`.
docstr_tok: ["Data","loader","that","balances","data","from","multiple","datasets","emitting","an","infinite","stream",".","Mini-batches","emitted","by","this","dataloader","are","created","by","collating","together","mini-batches","from","each","group",".","It","may","be","used","to","balance","data","among","classes",",","experiences",",","tasks",",","and","so","on",".",":","param","datasets",":","an","instance","of","`","AvalancheDataset","`",".",":","param","batch_size",":","the","size","of","the","batch","to","take","from","each","dataset",".","Please","note","that",",","differently","from","other","Avalanche","multi","dataset","loaders",",","this","value","is","the","per-dataset","contribution","to","the","final","mini-batch",",","NOT","the","final","mini-batch","size",".","The","final","mini-batches","will","be","of","size","`","len","(","datasets",")","*","batch_size","`",".",":","param","distributed_sampling",":","If","True",",","apply","the","PyTorch",":","class",":","`","DistributedSampler","`",".","Defaults","to","True",".","Note",":","the","distributed","sampler","is","not","applied","if","not","running","a","distributed","training",",","even","when","True","is","passed",".",":","param","kwargs",":","data","loader","arguments","used","to","instantiate","the","loader","for","each","group","separately",".","See","pytorch",":","class",":","`","DataLoader","`","."]
code: def __init__(
      self,
      datasets: Sequence[AvalancheDataset],
      batch_size=32,
      distributed_sampling: bool = True,
      **kwargs,
  ):
      """Data loader that balances data from multiple datasets emitting an
      infinite stream.
  
      Mini-batches emitted by this dataloader are created by collating
      together mini-batches from each group. It may be used to balance data
      among classes, experiences, tasks, and so on.
  
      :param datasets: an instance of `AvalancheDataset`.
      :param batch_size: the size of the batch to take from each dataset.
          Please note that, differently from other Avalanche multi dataset
          loaders, this value is the per-dataset contribution to the
          final mini-batch, NOT the final mini-batch size. The final
          mini-batches will be of size `len(datasets) * batch_size`.
      :param distributed_sampling: If True, apply the PyTorch
          :class:`DistributedSampler`. Defaults to True.
          Note: the distributed sampler is not applied if not running
          a distributed training, even when True is passed.
      :param kwargs: data loader arguments used to instantiate the loader for
          each group separately. See pytorch :class:`DataLoader`.
      """
  
      batch_sizes = [batch_size] * len(datasets)
  
      super().__init__(
          datasets,
          batch_sizes,
          termination_dataset=-1,
          oversample_small_datasets=True,
          distributed_sampling=distributed_sampling,
          never_ending=True,
          **kwargs,
      )
  
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 GroupBalancedInfiniteDataLoader object from inherited base classes: MultiDatasetDataLoader with example: obj = GroupBalancedInfiniteDataLoader(datasets, batch_size, distributed_sampling)