class_docstr: Samples a mini-batch of indices for a balanced class batching
  
  Args:
      dataset_items(list): dataset items to sample from.
      classes (list): list of classes of dataset_items to sample from.
      batch_size (int): total number of samples to be sampled in a mini-batch.
      num_gpus (int): number of GPU in the data parallel mode.
      shuffle (bool): if True, samples randomly, otherwise samples sequentially.
      drop_last (bool): if True, drops last incomplete batch.
class_docstr_tok: ["Samples","a","mini-batch","of","indices","for","a","balanced","class","batching","Args",":","dataset_items","(","list",")",":","dataset","items","to","sample","from",".","classes","(","list",")",":","list","of","classes","of","dataset_items","to","sample","from",".","batch_size","(","int",")",":","total","number","of","samples","to","be","sampled","in","a","mini-batch",".","num_gpus","(","int",")",":","number","of","GPU","in","the","data","parallel","mode",".","shuffle","(","bool",")",":","if","True",",","samples","randomly",",","otherwise","samples","sequentially",".","drop_last","(","bool",")",":","if","True",",","drops","last","incomplete","batch","."]
code: def __len__(self):
      class_batch_size = self._batch_size // self._num_classes_in_batch
      return min(
          ((len(s) + class_batch_size - 1) // class_batch_size)
          for s in self._samplers
      )
  
imports: import math
  import random
  from typing import Callable, List, Union
  from torch.utils.data.sampler import BatchSampler, Sampler, SubsetRandomSampler
label_desc: Use image node_id 3 for calling the PerfectBatchSampler obj's underlying member method code with example usage: obj.__len__() and returns: min