class_docstr: Dataloader which wraps another dataloader and only returns a limited
  number of items.
  
  This is useful for Iterable datasets where the length of the datasets isn't known.
  Such datasets can wrap their returned iterators with this class. See
  :func:`SyntheticImageStreamingDataset.iterator` for an example.
  
  Attribute accesses are passed to the wrapped dataloader.
docstr: Constructor for DataloaderLimitWrapper.
  
  Args:
      dataloader: The dataloader to wrap around
      limit: Specify the number of calls to the underlying dataloader. The wrapper
          will raise a `StopIteration` after `limit` calls.
      wrap_around: Whether to wrap around the original datatloader if the
          dataloader is exhausted before `limit` calls.
  Raises:
      RuntimeError: If `wrap_around` is set to `False` and the underlying
          dataloader is exhausted before `limit` calls.
docstr_tok: ["Constructor","for","DataloaderLimitWrapper",".","Args",":","dataloader",":","The","dataloader","to","wrap","around","limit",":","Specify","the","number","of","calls","to","the","underlying","dataloader",".","The","wrapper","will","raise","a","`","StopIteration","`","after","`","limit","`","calls",".","wrap_around",":","Whether","to","wrap","around","the","original","datatloader","if","the","dataloader","is","exhausted","before","`","limit","`","calls",".","Raises",":","RuntimeError",":","If","`","wrap_around","`","is","set","to","`","False","`","and","the","underlying","dataloader","is","exhausted","before","`","limit","`","calls","."]
code: def __init__(
      self, dataloader: Iterable, limit: int, wrap_around: bool = True
  ) -> None:
      """Constructor for DataloaderLimitWrapper.
  
      Args:
          dataloader: The dataloader to wrap around
          limit: Specify the number of calls to the underlying dataloader. The wrapper
              will raise a `StopIteration` after `limit` calls.
          wrap_around: Whether to wrap around the original datatloader if the
              dataloader is exhausted before `limit` calls.
      Raises:
          RuntimeError: If `wrap_around` is set to `False` and the underlying
              dataloader is exhausted before `limit` calls.
      """
      super().__init__(dataloader)
      # we use self.__dict__ to set the attributes since the __setattr__ method
      # is overridden
      attributes = {
          "limit": limit,
          "wrap_around": wrap_around,
          "_count": None,
      }
      self.__dict__.update(attributes)
  
file_path: ClassyVision/classy_vision/dataset/dataloader_limit_wrapper.py
imports: import logging
  from typing import Any, Iterable, Iterator
  from .dataloader_wrapper import DataloaderWrapper
label_desc: Use image node_id 1 to create a new DataloaderLimitWrapper object from inherited base classes: DataloaderWrapper with example: obj = DataloaderLimitWrapper(dataloader, limit, wrap_around)