class_docstr: A sharded wrapper around an iterable (padded to length).
  
  Parameters
  ----------
  sampler
  num_parts
      Number of partitions which the data is split into (default: 1)
  part_index
      The index of the part to read from
  even_size
      If the number of batches is not even across all partitions, sample a few extra batches
      for the ones with fewer batches.
class_docstr_tok: ["A","sharded","wrapper","around","an","iterable","(","padded","to","length",")",".","Parameters","--","--","--","--","--","sampler","num_parts","Number","of","partitions","which","the","data","is","split","into","(","default",":","1",")","part_index","The","index","of","the","part","to","read","from","even_size","If","the","number","of","batches","is","not","even","across","all","partitions",",","sample","a","few","extra","batches","for","the","ones","with","fewer","batches","."]
code: def __init__(
      self,
      sampler: BaseSampler,
      num_parts: int = 1,
      part_index: int = 0,
      even_size: bool = False,
      seed: Optional[int] = None,
  ):
      assert (
          part_index < num_parts
      ), "part_index should be less than num_parts"
      self._sampler = sampler
      self._num_parts = num_parts
      self._part_index = part_index
      self._even_size = even_size
      self._rng = np.random.RandomState(seed)
  
      length = len(sampler)
      if not even_size:
          part_len = length // num_parts
          remaining = length % num_parts
          self._start = part_len * part_index + min(
              part_index, remaining
          )
          self._end = self._start + part_len + (part_index < remaining)
          self._part_len = self._end - self._start
      else:
          part_len = int(length + num_parts - 1) // num_parts
          self._start = part_len * part_index
          self._end = self._start + part_len
          self._start = self._start if self._start < length else length
          self._end = self._end if self._end < length else length
          self._part_len = part_len
  
imports: import math
  import random
  import warnings
  import numpy
  import abc
  import logging
  from typing import Union, Sequence, Optional, List
  from ..base import INT_TYPES
label_desc: Use image node_id 1 to create a new ShardedIterator object from inherited base classes: BaseSampler with example: obj = ShardedIterator(sampler, num_parts, part_index, even_size, seed)