class_docstr: A wrapper of repeated dataset with repeat factor.
  
  Suitable for training on class imbalanced datasets like LVIS. Following
  the sampling strategy in the `paper <https://arxiv.org/abs/1908.03195>`_,
  in each epoch, an image may appear multiple times based on its
  "repeat factor".
  The repeat factor for an image is a function of the frequency the rarest
  category labeled in that image. The "frequency of category c" in [0, 1]
  is defined by the fraction of images in the training set (without repeats)
  in which category c appears.
  The dataset needs to instantiate :func:`self.get_cat_ids` to support
  ClassBalancedDataset.
  
  The repeat factor is computed as followed.
  
  1. For each category c, compute the fraction # of images
     that contain it: :math:`f(c)`
  2. For each category c, compute the category-level repeat factor:
     :math:`r(c) = max(1, sqrt(t/f(c)))`
  3. For each image I, compute the image-level repeat factor:
     :math:`r(I) = max_{c in I} r(c)`
  
  Args:
      dataset (:obj:`CustomDataset`): The dataset to be repeated.
      oversample_thr (float): frequency threshold below which data is
          repeated. For categories with ``f_c >= oversample_thr``, there is
          no oversampling. For categories with ``f_c < oversample_thr``, the
          degree of oversampling following the square-root inverse frequency
          heuristic above.
      filter_empty_gt (bool, optional): If set true, images without bounding
          boxes will not be oversampled. Otherwise, they will be categorized
          as the pure background class and involved into the oversampling.
          Default: True.
docstr: Get repeat factor for each images in the dataset.
  
  Args:
      dataset (:obj:`CustomDataset`): The dataset
      repeat_thr (float): The threshold of frequency. If an image
          contains the categories whose frequency below the threshold,
          it would be repeated.
  
  Returns:
      list[float]: The repeat factors for each images in the dataset.
docstr_tok: ["Get","repeat","factor","for","each","images","in","the","dataset",".","Args",":","dataset","(",":","obj",":","`","CustomDataset","`",")",":","The","dataset","repeat_thr","(","float",")",":","The","threshold","of","frequency",".","If","an","image","contains","the","categories","whose","frequency","below","the","threshold",",","it","would","be","repeated",".","Returns",":","list","[","float","]",":","The","repeat","factors","for","each","images","in","the","dataset","."]
code: def _get_repeat_factors(self, dataset, repeat_thr):
      """Get repeat factor for each images in the dataset.
  
      Args:
          dataset (:obj:`CustomDataset`): The dataset
          repeat_thr (float): The threshold of frequency. If an image
              contains the categories whose frequency below the threshold,
              it would be repeated.
  
      Returns:
          list[float]: The repeat factors for each images in the dataset.
      """
  
      # 1. For each category c, compute the fraction # of images
      #   that contain it: f(c)
      category_freq = defaultdict(int)
      num_images = len(dataset)
      for idx in range(num_images):
          cat_ids = set(self.dataset.get_cat_ids(idx))
          if len(cat_ids) == 0 and not self.filter_empty_gt:
              cat_ids = set([len(self.CLASSES)])
          for cat_id in cat_ids:
              category_freq[cat_id] += 1
      for k, v in category_freq.items():
          category_freq[k] = v / num_images
  
      # 2. For each category c, compute the category-level repeat factor:
      #    r(c) = max(1, sqrt(t/f(c)))
      category_repeat = {
          cat_id: max(1.0, math.sqrt(repeat_thr / cat_freq))
          for cat_id, cat_freq in category_freq.items()
      }
  
      # 3. For each image I, compute the image-level repeat factor:
      #    r(I) = max_{c in I} r(c)
      repeat_factors = []
      for idx in range(num_images):
          cat_ids = set(self.dataset.get_cat_ids(idx))
          if len(cat_ids) == 0 and not self.filter_empty_gt:
              cat_ids = set([len(self.CLASSES)])
          repeat_factor = 1
          if len(cat_ids) > 0:
              repeat_factor = max(
                  {category_repeat[cat_id] for cat_id in cat_ids}
              )
          repeat_factors.append(repeat_factor)
  
      return repeat_factors
  
imports: import bisect
  import math
  from collections import defaultdict
  import numpy
  from mmcv.utils import print_log
  from torch.utils.data.dataset import ConcatDataset
  from .builder import DATASETS
  from .coco import CocoDataset
label_desc: Use image node_id 2 for calling the ClassBalancedDataset obj's underlying member method code with example usage: obj._get_repeat_factors(dataset, repeat_thr) and returns: repeat_factors