class_docstr: A sampler wrapper for grouping images with similar aspect ratio (< 1 or.
  
  >= 1) into a same batch for multi-source datasets.
  
  Args:
      sampler (Sampler): Base sampler.
      batch_size (Sequence(int)): Size of mini-batch for multi-source
      datasets.
      num_datasets(int): Number of multi-source datasets.
      drop_last (bool): If ``True``, the sampler will drop the last batch if
      its size would be less than ``batch_size``.
class_docstr_tok: ["A","sampler","wrapper","for","grouping","images","with","similar","aspect","ratio","(","<","1","or",".",">","=","1",")","into","a","same","batch","for","multi-source","datasets",".","Args",":","sampler","(","Sampler",")",":","Base","sampler",".","batch_size","(","Sequence","(","int",")",")",":","Size","of","mini-batch","for","multi-source","datasets",".","num_datasets","(","int",")",":","Number","of","multi-source","datasets",".","drop_last","(","bool",")",":","If","``","True","``",",","the","sampler","will","drop","the","last","batch","if","its","size","would","be","less","than","``","batch_size","``","."]
code: def __iter__(self) -> Sequence[int]:
      for idx in self.sampler:
          data_info = self.sampler.dataset.get_data_info(idx)
          width, height = data_info["width"], data_info["height"]
          dataset_source_idx = self.sampler.dataset.get_dataset_source(
              idx
          )
          aspect_ratio_bucket_id = 0 if width < height else 1
          bucket_id = dataset_source_idx * 2 + aspect_ratio_bucket_id
          bucket = self._buckets[bucket_id]
          bucket.append(idx)
          # yield a batch of indices in the same aspect ratio group
          if len(bucket) == self.batch_size[dataset_source_idx]:
              yield bucket[:]
              del bucket[:]
  
      # yield the rest data and reset the bucket
      for i in range(self.num_datasets):
          left_data = (
              self._buckets[i * 2 + 0] + self._buckets[i * 2 + 1]
          )
          while len(left_data) > 0:
              if len(left_data) <= self.batch_size[i]:
                  if not self.drop_last:
                      yield left_data[:]
                  left_data = []
              else:
                  yield left_data[: self.batch_size[i]]
                  left_data = left_data[self.batch_size[i] :]
  
      self._buckets = [[] for _ in range(2 * self.num_datasets)]
  
file_path: mmdetection/mmdet/datasets/samplers/batch_sampler.py
imports: from typing import Sequence
  from torch.utils.data import BatchSampler, Sampler
  from mmdet.datasets.samplers.track_img_sampler import TrackImgSampler
  from mmdet.registry import DATA_SAMPLERS
label_desc: Use image node_id 2 for calling the MultiDataAspectRatioBatchSampler obj's underlying member method code with example usage: obj.__iter__() without return types