class_docstr: The Pytree Loader is the default loader of the Cache object.
class_docstr_tok: ["The","Pytree","Loader","is","the","default","loader","of","the","Cache","object","."]
code: def load_item_from_chunk(
      self,
      index: int,
      chunk_index: int,
      chunk_filepath: str,
      begin: int,
  ) -> bytes:
      offset = (
          1 + (index - begin) if index >= begin else index + 1
      ) * 4
  
      if (
          chunk_filepath in self._chunk_filepaths
          and not os.path.isfile(chunk_filepath)
      ):
          del self._chunk_filepaths[chunk_filepath]
  
      if chunk_filepath not in self._chunk_filepaths:
          first_exists = exists = os.path.exists(chunk_filepath)
  
          while not exists:
              sleep(0.1)
              exists = os.path.exists(chunk_filepath)
  
          # Wait to avoid any corruption when the file appears
          if not first_exists:
              sleep(0.001)
  
          self._chunk_filepaths[chunk_filepath] = True
  
      with open(chunk_filepath, "rb", 0) as fp:
          fp.seek(offset)
          pair = fp.read(8)
          begin, end = np.frombuffer(pair, np.uint32)
          fp.seek(begin)
          data = fp.read(end - begin)
      return self.deserialize(data)
  
imports: import os
  from abc import ABC, abstractmethod
  from time import sleep
  from typing import Any, Dict, List, Optional, Tuple
  import numpy
  import torch
  from lightning.data.streaming.constants import _TORCH_DTYPES_MAPPING, _TORCH_GREATER_EQUAL_2_1_0
  from lightning.data.streaming.serializers import Serializer
label_desc: Use image node_id 4 for calling the PyTreeLoader obj's underlying member method code with example usage: obj.load_item_from_chunk(index, chunk_index, chunk_filepath, begin) and returns: self