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","."]
code: def __iter__(self) -> Iterator[Any]:
      shuffled_indices: List[int] = []
      for i, size in enumerate(self.group_sizes):
          if size > 0:
              group_indices = np.where(self.flag == i)[0]
              assert len(group_indices) == size
              shuffled_group_indices: List[int] = group_indices[
                  list(torch.randperm(int(size)))
              ].tolist()
              extra = int(
                  math.ceil(
                      size
                      * 1.0
                      / self.samples_per_gpu
                      / self.num_replicas
                  )
              ) * self.samples_per_gpu * self.num_replicas - len(
                  shuffled_group_indices
              )
              # pad index
              tmp = shuffled_group_indices.copy()
              for _ in range(extra // size):
                  shuffled_group_indices.extend(tmp)
              shuffled_group_indices.extend(tmp[: extra % size])
              shuffled_indices.extend(shuffled_group_indices)
  
      assert len(shuffled_indices) == self.total_size
  
      shuffled_indices = [
          shuffled_indices[j]
          for i in list(
              torch.randperm(
                  len(shuffled_indices) // self.samples_per_gpu
              )
          )
          for j in range(
              i * self.samples_per_gpu, (i + 1) * self.samples_per_gpu
          )
      ]
  
      return iter(shuffled_indices)
  
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 2 for calling the GroupSampler obj's underlying member method code with example usage: obj.__iter__() and returns: iter