class_docstr: Batch data that have similar aspect ratio together.
  In this implementation, images whose aspect ratio < (or >) 1 will
  be batched together.
  This improves training speed because the images then need less padding
  to form a batch.
  
  It assumes the underlying dataset produces dicts with "width" and "height" keys.
  It will then produce a list of original dicts with length = batch_size,
  all with similar aspect ratios.
class_docstr_tok: ["Batch","data","that","have","similar","aspect","ratio","together",".","In","this","implementation",",","images","whose","aspect","ratio","<","(","or",">",")","1","will","be","batched","together",".","This","improves","training","speed","because","the","images","then","need","less","padding","to","form","a","batch",".","It","assumes","the","underlying","dataset","produces","dicts","with","``","width","''","and","``","height","''","keys",".","It","will","then","produce","a","list","of","original","dicts","with","length","=","batch_size",",","all","with","similar","aspect","ratios","."]
docstr: Args:
      dataset: an iterable. Each element must be a dict with keys
          "width" and "height", which will be used to batch data.
      batch_size (int):
docstr_tok: ["Args",":","dataset",":","an","iterable",".","Each","element","must","be","a","dict","with","keys","``","width","''","and","``","height","''",",","which","will","be","used","to","batch","data",".","batch_size","(","int",")",":"]
code: def __init__(self, dataset, batch_size):
      """
      Args:
          dataset: an iterable. Each element must be a dict with keys
              "width" and "height", which will be used to batch data.
          batch_size (int):
      """
      self.dataset = dataset
      self.batch_size = batch_size
      self._buckets = [[] for _ in range(2)]
  
imports: import itertools
  import random
  import logging
  import operator
  import dill
  import pickle
  from pprint import pformat
  from typing import List, Optional, Union
  import numpy
  import torch
  import torch.utils.data
  from ..structures import BoxMode
  from ...utils.comm import get_world_size
  from ...utils.random import seed_all_rng
  from ..transforms import instance_transforms
  from ..registry.catalog import DatasetCatalog, MetadataCatalog
  from .detection_utils import check_metadata_consistency
  from .None import detection_utils
  from .samplers import InferenceSampler, RepeatFactorTrainingSampler, TrainingSampler
label_desc: Use image node_id 1 to create a new AspectRatioGroupedDataset object from inherited base classes: data with example: obj = AspectRatioGroupedDataset(dataset, batch_size)