docstr: The BinaryReader enables to read chunked dataset in an efficient way.
  
  Arguments:
      cache_dir: The path to cache folder.
      remote_input_dir: The path to a remote folder where the data are located.
          The scheme needs to be added to the path.
      compression: The algorithm to decompress the chunks.
      item_loader: The chunk sampler to create sub arrays from a chunk.
      max_cache_size: The maximum cache size used by the reader when fetching the chunks.
      serializers: Provide your own serializers.
docstr_tok: ["The","BinaryReader","enables","to","read","chunked","dataset","in","an","efficient","way",".","Arguments",":","cache_dir",":","The","path","to","cache","folder",".","remote_input_dir",":","The","path","to","a","remote","folder","where","the","data","are","located",".","The","scheme","needs","to","be","added","to","the","path",".","compression",":","The","algorithm","to","decompress","the","chunks",".","item_loader",":","The","chunk","sampler","to","create","sub","arrays","from","a","chunk",".","max_cache_size",":","The","maximum","cache","size","used","by","the","reader","when","fetching","the","chunks",".","serializers",":","Provide","your","own","serializers","."]
code: def __init__(
      self,
      cache_dir: str,
      max_cache_size: Optional[Union[int, str]] = None,
      remote_input_dir: Optional[str] = None,
      compression: Optional[str] = None,
      item_loader: Optional[BaseItemLoader] = None,
      serializers: Optional[Dict[str, Serializer]] = None,
  ) -> None:
      """The BinaryReader enables to read chunked dataset in an efficient way.
  
      Arguments:
          cache_dir: The path to cache folder.
          remote_input_dir: The path to a remote folder where the data are located.
              The scheme needs to be added to the path.
          compression: The algorithm to decompress the chunks.
          item_loader: The chunk sampler to create sub arrays from a chunk.
          max_cache_size: The maximum cache size used by the reader when fetching the chunks.
          serializers: Provide your own serializers.
  
      """
      super().__init__()
      warnings.filterwarnings(
          "ignore", message=".*The given buffer is not writable.*"
      )
  
      self._cache_dir = cache_dir
      self._remote_input_dir = remote_input_dir
  
      if not os.path.exists(self._cache_dir):
          raise FileNotFoundError(
              f"The provided cache_dir `{self._cache_dir}` doesn't exist."
          )
  
      self._compression = compression
      self._intervals: Optional[List[str]] = None
  
      self._serializers: Dict[str, Serializer] = _get_serializers(
          serializers
      )
      self._distributed_env = _DistributedEnv.detect()
      self._rank: Optional[int] = None
      self._config: Optional[ChunksConfig] = None
      self._prepare_thread: Optional[PrepareChunksThread] = None
      self._item_loader = item_loader or PyTreeLoader()
      self._last_chunk_index: Optional[int] = None
      self._max_cache_size = int(
          os.getenv("MAX_CACHE_SIZE", max_cache_size or 0)
      )
  
imports: import contextlib
  import multiprocessing
  import os
  import warnings
  from logging import Logger
  from queue import Empty
  from threading import Thread
  from typing import Any, Dict, List, Optional, Tuple, Union
  from lightning.data.streaming.config import ChunksConfig
  from lightning.data.streaming.constants import _TORCH_GREATER_EQUAL_2_1_0
  from lightning.data.streaming.item_loader import BaseItemLoader, PyTreeLoader
  from lightning.data.streaming.sampler import ChunkedIndex
  from lightning.data.streaming.serializers import Serializer, _get_serializers
  from lightning.data.utilities.env import _DistributedEnv, _WorkerEnv
label_desc: Use image node_id 1 to create a new BinaryReader object  with example: obj = BinaryReader(cache_dir, max_cache_size, remote_input_dir, compression, item_loader, serializers)