class_docstr: Produce indices for inference across all workers.
  Inference needs to run on the __exact__ set of samples,
  therefore when the total number of samples is not divisible by the number of workers,
  this sampler produces different number of samples on different workers.
class_docstr_tok: ["Produce","indices","for","inference","across","all","workers",".","Inference","needs","to","run","on","the","__exact__","set","of","samples",",","therefore","when","the","total","number","of","samples","is","not","divisible","by","the","number","of","workers",",","this","sampler","produces","different","number","of","samples","on","different","workers","."]
docstr: Args:
      size (int): the total number of data of the underlying dataset to sample from
docstr_tok: ["Args",":","size","(","int",")",":","the","total","number","of","data","of","the","underlying","dataset","to","sample","from"]
code: def __init__(self, size: int):
      """
      Args:
          size (int): the total number of data of the underlying dataset to sample from
      """
      self._size = size
      assert size > 0
      self._rank = comm.get_rank()
      self._world_size = comm.get_world_size()
      self._local_indices = self._get_local_indices(
          size, self._world_size, self._rank
      )
  
imports: import itertools
  import logging
  import math
  from collections import defaultdict
  from typing import Optional
  import torch
  from torch.utils.data.sampler import Sampler
  from detectron2.utils import comm
label_desc: Use image node_id 1 to create a new InferenceSampler object from inherited base classes: Sampler with example: obj = InferenceSampler(size)