class_docstr: Modifies DistributedGroupSampler from
  https://github.com/open-mmlab/mmdetection/blob/master/mmdet/datasets/samplers/group_sampler.py
  to work with our Dataloader which automatically handles sharding for distributed training.
class_docstr_tok: ["Modifies","DistributedGroupSampler","from","https",":","\/\/github.com\/open-mmlab\/mmdetection\/blob\/master\/mmdet\/datasets\/samplers\/group_sampler.py","to","work","with","our","Dataloader","which","automatically","handles","sharding","for","distributed","training","."]
docstr: This sampler will generate indices such that each batch will belong to the same group.
  For example, if batch size is `b`, samples 1 to b will be one group, samples b+1 to 2b
  another group, etc. Hence, we effectively have len(dataset)/batch_size group indices which
  get shuffled every epoch.
  
  Arguments:
      dataset: dataset that has a flag attribute to indicate group member for each sample.
      samples_per_gpu: number of samples per slot.
      num_replicas: number of processes participating in distributed training.
docstr_tok: ["This","sampler","will","generate","indices","such","that","each","batch","will","belong","to","the","same","group",".","For","example",",","if","batch","size","is","`","b","`",",","samples","1","to","b","will","be","one","group",",","samples","b+1","to","2b","another","group",",","etc",".","Hence",",","we","effectively","have","len","(","dataset",")","\/batch_size","group","indices","which","get","shuffled","every","epoch",".","Arguments",":","dataset",":","dataset","that","has","a","flag","attribute","to","indicate","group","member","for","each","sample",".","samples_per_gpu",":","number","of","samples","per","slot",".","num_replicas",":","number","of","processes","participating","in","distributed","training","."]
code: def __init__(
      self,
      dataset: torch_data.Dataset,
      samples_per_gpu: int,
      num_replicas: int,
  ):
      """
      This sampler will generate indices such that each batch will belong to the same group.
      For example, if batch size is `b`, samples 1 to b will be one group, samples b+1 to 2b
      another group, etc. Hence, we effectively have len(dataset)/batch_size group indices which
      get shuffled every epoch.
  
      Arguments:
          dataset: dataset that has a flag attribute to indicate group member for each sample.
          samples_per_gpu: number of samples per slot.
          num_replicas: number of processes participating in distributed training.
      """
      self.dataset = dataset
      self.samples_per_gpu = samples_per_gpu
      self.num_replicas = num_replicas
  
      assert hasattr(self.dataset, "flag")
      self.flag = self.dataset.flag  # type: ignore
      self.group_sizes = np.bincount(self.flag)
  
      self.num_samples = 0
      for size in self.group_sizes:
          self.num_samples += (
              int(
                  math.ceil(
                      size
                      * 1.0
                      / self.samples_per_gpu
                      / self.num_replicas
                  )
              )
              * self.samples_per_gpu
          )
      self.total_size = self.num_samples * self.num_replicas
  
imports: import functools
  import logging
  import math
  import os
  from typing import Any, Iterator, List, Tuple
  import filelock
  import mmcv
  import mmcv.parallel
  import mmdet.datasets
  import numpy
  import torch
  import torch.utils.data
  import determined.pytorch
label_desc: Use image node_id 1 to create a new GroupSampler object from inherited base classes: torch.utils.data with example: obj = GroupSampler(dataset, samples_per_gpu, num_replicas)