class_docstr: Group Multi-Source Infinite Sampler.
  
  According to the sampling ratio, sample data from different
  datasets but the same group to form batches.
  
  Args:
      dataset (Sized): The dataset.
      batch_size (int): Size of mini-batch.
      source_ratio (list[int | float]): The sampling ratio of different
          source datasets in a mini-batch.
      shuffle (bool): Whether shuffle the dataset or not. Defaults to True.
      seed (int, optional): Random seed. If None, set a random seed.
          Defaults to None.
class_docstr_tok: ["Group","Multi-Source","Infinite","Sampler",".","According","to","the","sampling","ratio",",","sample","data","from","different","datasets","but","the","same","group","to","form","batches",".","Args",":","dataset","(","Sized",")",":","The","dataset",".","batch_size","(","int",")",":","Size","of","mini-batch",".","source_ratio","(","list","[","int","|","float","]",")",":","The","sampling","ratio","of","different","source","datasets","in","a","mini-batch",".","shuffle","(","bool",")",":","Whether","shuffle","the","dataset","or","not",".","Defaults","to","True",".","seed","(","int",",","optional",")",":","Random","seed",".","If","None",",","set","a","random","seed",".","Defaults","to","None","."]
code: def __init__(
      self,
      dataset: BaseDataset,
      batch_size: int,
      source_ratio: List[Union[int, float]],
      shuffle: bool = True,
      seed: Optional[int] = None,
  ) -> None:
      super().__init__(
          dataset=dataset,
          batch_size=batch_size,
          source_ratio=source_ratio,
          shuffle=shuffle,
          seed=seed,
      )
  
      self._get_source_group_info()
      self.group_source2inds = [
          {
              source: self._indices_of_rank(
                  self.group2size_per_source[source][group]
              )
              for source in range(len(dataset.datasets))
          }
          for group in range(len(self.group_ratio))
      ]
  
imports: import itertools
  from typing import Iterator, List, Optional, Sized, Union
  import numpy
  import torch
  from mmengine.dataset import BaseDataset
  from mmengine.dist import get_dist_info, sync_random_seed
  from torch.utils.data import Sampler
  from mmdet.registry import DATA_SAMPLERS
label_desc: Use image node_id 1 to create a new GroupMultiSourceSampler object from inherited base classes: MultiSourceSampler with example: obj = GroupMultiSourceSampler(dataset, batch_size, source_ratio, shuffle, seed)