class_docstr: This class is used to wrap a :class:`torch.utils.data.BatchSampler` and capture its indices.
class_docstr_tok: ["This","class","is","used","to","wrap","a",":","class",":","`","torch.utils.data.BatchSampler","`","and","capture","its","indices","."]
code: def __init__(self, batch_sampler: _SizedIterable) -> None:
      # do not call super().__init__() on purpose
      self.seen_batch_indices: List[List[int]] = []
  
      self.__dict__ = {
          k: v
          for k, v in batch_sampler.__dict__.items()
          if k
          not in ("__next__", "__iter__", "__len__", "__getstate__")
      }
      self._batch_sampler = batch_sampler
      self._iterator: Optional[Iterator[List[int]]] = None
  
imports: import itertools
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sized, Union, cast
  import torch
  from torch import Tensor
  from torch.nn.parallel.distributed import DistributedDataParallel
  from torch.utils.data import DistributedSampler, Sampler
  from typing_extensions import Self
  from lightning.fabric.utilities.distributed import _DatasetSamplerWrapper
  from lightning.pytorch.utilities.rank_zero import rank_zero_debug, rank_zero_info
  from lightning.pytorch.utilities.types import _SizedIterable
label_desc: Use image node_id 1 to create a new _IndexBatchSamplerWrapper object  with example: obj = _IndexBatchSamplerWrapper(batch_sampler)