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 __iter__(self) -> Iterator[int]:
      batch_buffer = []
      while True:
          group = np.random.choice(
              list(range(len(self.group_ratio))), p=self.group_ratio
          )
          for source, num in enumerate(self.num_per_source):
              batch_buffer_per_source = []
              for idx in self.group_source2inds[group][source]:
                  idx = (
                      self.group2inds_per_source[source][group][idx]
                      + self.cumulative_sizes[source]
                  )
                  batch_buffer_per_source.append(idx)
                  if len(batch_buffer_per_source) == num:
                      batch_buffer += batch_buffer_per_source
                      break
          yield from batch_buffer
          batch_buffer = []
  
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 3 for calling the GroupMultiSourceSampler obj's underlying member method code with example usage: obj.__iter__() without return types