class_docstr: Similar to TrainingSampler, but a sample may appear more times than others based
  on its "repeat factor". This is suitable for training on class imbalanced datasets like LVIS.
class_docstr_tok: ["Similar","to","TrainingSampler",",","but","a","sample","may","appear","more","times","than","others","based","on","its","``","repeat","factor","''",".","This","is","suitable","for","training","on","class","imbalanced","datasets","like","LVIS","."]
docstr: Args:
      repeat_factors (Tensor): a float vector, the repeat factor for each indice. When it's
          full of ones, it is equivalent to ``TrainingSampler(len(repeat_factors), ...)``.
      shuffle (bool): whether to shuffle the indices or not
      seed (int): the initial seed of the shuffle. Must be the same
          across all workers. If None, will use a random seed shared
          among workers (require synchronization among all workers).
docstr_tok: ["Args",":","repeat_factors","(","Tensor",")",":","a","float","vector",",","the","repeat","factor","for","each","indice",".","When","it's","full","of","ones",",","it","is","equivalent","to","``","TrainingSampler","(","len","(","repeat_factors",")",",","...",")","``",".","shuffle","(","bool",")",":","whether","to","shuffle","the","indices","or","not","seed","(","int",")",":","the","initial","seed","of","the","shuffle",".","Must","be","the","same","across","all","workers",".","If","None",",","will","use","a","random","seed","shared","among","workers","(","require","synchronization","among","all","workers",")","."]
code: def __init__(self, repeat_factors, *, shuffle=True, seed=None):
      """
      Args:
          repeat_factors (Tensor): a float vector, the repeat factor for each indice. When it's
              full of ones, it is equivalent to ``TrainingSampler(len(repeat_factors), ...)``.
          shuffle (bool): whether to shuffle the indices or not
          seed (int): the initial seed of the shuffle. Must be the same
              across all workers. If None, will use a random seed shared
              among workers (require synchronization among all workers).
      """
      self._shuffle = shuffle
      if seed is None:
          seed = comm.shared_random_seed()
      self._seed = int(seed)
  
      self._rank = comm.get_rank()
      self._world_size = comm.get_world_size()
  
      # Split into whole number (_int_part) and fractional (_frac_part) parts.
      self._int_part = torch.trunc(repeat_factors)
      self._frac_part = repeat_factors - self._int_part
  
imports: import itertools
  import math
  from collections import defaultdict
  from typing import Optional
  import torch
  from torch.utils.data.sampler import Sampler
  from ....utils import comm
label_desc: Use image node_id 1 to create a new RepeatFactorTrainingSampler object from inherited base classes: Sampler with example: obj = RepeatFactorTrainingSampler(repeat_factors)