class_docstr: Variably-size multi-scale batch sampler <https://arxiv.org/abs/2110.02178?context=cs.LG>` for data parallel.
  This sampler yields batches with variable spatial resolution and batch size.
  
  Args:
      opts: command line argument
      n_data_samples: Number of samples in the dataset
      is_training: Training or validation mode. Default: False
class_docstr_tok: ["Variably-size","multi-scale","batch","sampler","<","https",":","\/\/arxiv.org\/abs\/2110.02178","?","context=cs.LG",">","`","for","data","parallel",".","This","sampler","yields","batches","with","variable","spatial","resolution","and","batch","size",".","Args",":","opts",":","command","line","argument","n_data_samples",":","Number","of","samples","in","the","dataset","is_training",":","Training","or","validation","mode",".","Default",":","False"]
code: def __init__(
      self,
      opts: argparse.Namespace,
      n_data_samples: int,
      is_training: bool = False,
      *args,
      **kwargs,
  ) -> None:
      super().__init__(
          opts=opts,
          n_data_samples=n_data_samples,
          is_training=is_training,
      )
  
      crop_size_w = getattr(opts, "sampler.vbs.crop_size_width")
      crop_size_h = getattr(opts, "sampler.vbs.crop_size_height")
  
      min_crop_size_w = getattr(opts, "sampler.vbs.min_crop_size_width")
      max_crop_size_w = getattr(opts, "sampler.vbs.max_crop_size_width")
  
      min_crop_size_h = getattr(
          opts, "sampler.vbs.min_crop_size_height"
      )
      max_crop_size_h = getattr(
          opts, "sampler.vbs.max_crop_size_height"
      )
  
      check_scale_div_factor = getattr(opts, "sampler.vbs.check_scale")
      max_img_scales = getattr(opts, "sampler.vbs.max_n_scales")
  
      scale_inc = getattr(opts, "sampler.vbs.scale_inc")
      min_scale_inc_factor = getattr(
          opts, "sampler.vbs.min_scale_inc_factor"
      )
      max_scale_inc_factor = getattr(
          opts, "sampler.vbs.max_scale_inc_factor"
      )
      scale_ep_intervals = getattr(opts, "sampler.vbs.ep_intervals")
      if isinstance(scale_ep_intervals, int):
          scale_ep_intervals = [scale_ep_intervals]
  
      self.min_crop_size_w = min_crop_size_w
      self.max_crop_size_w = max_crop_size_w
      self.min_crop_size_h = min_crop_size_h
      self.max_crop_size_h = max_crop_size_h
  
      self.crop_size_w = crop_size_w
      self.crop_size_h = crop_size_h
  
      self.min_scale_inc_factor = min_scale_inc_factor
      self.max_scale_inc_factor = max_scale_inc_factor
      self.scale_ep_intervals = scale_ep_intervals
  
      self.max_img_scales = max_img_scales
      self.check_scale_div_factor = check_scale_div_factor
      self.scale_inc = scale_inc
  
      if is_training:
          self.img_batch_tuples = image_batch_pairs(
              crop_size_h=self.crop_size_h,
              crop_size_w=self.crop_size_w,
              batch_size_gpu0=self.batch_size_gpu0,
              n_gpus=self.n_gpus,
              max_scales=self.max_img_scales,
              check_scale_div_factor=self.check_scale_div_factor,
              min_crop_size_w=self.min_crop_size_w,
              max_crop_size_w=self.max_crop_size_w,
              min_crop_size_h=self.min_crop_size_h,
              max_crop_size_h=self.max_crop_size_h,
          )
      else:
          self.img_batch_tuples = [
              (crop_size_h, crop_size_w, self.batch_size_gpu0)
          ]
  
imports: import argparse
  import random
  from typing import Iterator, Tuple
  from common import DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH
  from data.sampler import SAMPLER_REGISTRY
  from data.sampler.base_sampler import BaseSampler, BaseSamplerDDP
  from data.sampler.utils import image_batch_pairs
  from utils import logger
label_desc: Use image node_id 1 to create a new VariableBatchSampler object from inherited base classes: BaseSampler with example: obj = VariableBatchSampler(opts, n_data_samples, is_training)