code: def __init__(
      self,
      dataset: Any,
      *args: Any,
      sampler: Optional[Sampler] = None,
      batch_sampler: Optional[BatchSampler] = None,
      num_workers: int = 0,
      shuffle: bool = False,
      generator: Optional[torch.Generator] = None,
      batch_size: Optional[int] = None,
      drop_last: bool = False,
      cache_dir: Optional[str] = None,
      chunk_bytes: Optional[int] = _DEFAULT_CHUNK_BYTES,
      compression: Optional[str] = None,
      profile: bool = False,
      collate_fn: Optional[Callable] = None,
      **kwargs: Any,
  ) -> None:
      if sampler:
          raise ValueError(
              "The CacheDataLoader relies on its own internal sampler. Passing a sampler isn't supported."
          )
  
      if batch_sampler:
          raise ValueError(
              "The CacheDataLoader relies on its own internal sampler. Passing a batch_sampler isn't supported."
          )
  
      if isinstance(dataset, IterableDataset):
          raise ValueError(
              "Only map-based dataset are supported by the CacheDataLoader for now."
          )
  
      if profile and not _VIZ_TRACKER_AVAILABLE:
          raise ModuleNotFoundError(
              "To enable DataLoader profiling, run `pip install viztracer`."
          )
  
      cache_list = [
          v for v in dataset.__dict__.values() if isinstance(v, Cache)
      ]
  
      if len(cache_list) > 1:
          raise ValueError(
              "We found several Cache used as attributes from your dataset. Only one is support for now."
          )
  
      if len(cache_list) == 0:
          if cache_dir is None:
              raise ValueError(
                  "You should provide a `cache_dir` filepath to the CacheDataLoader."
              )
  
          dataset = CacheDataset(
              dataset, cache_dir, chunk_bytes, batch_size, compression
          )
          cache = dataset._cache
      else:
          cache = cache_list[0]
  
      if not cache.filled and shuffle:
          logger.info(
              "Shuffle is ignored during the caching phase phase."
          )
  
      self._cache = cache
  
      distributed_env = _DistributedEnv.detect()
      self._global_rank = distributed_env.global_rank
  
      batch_sampler = CacheBatchSampler(
          len(dataset),
          distributed_env.world_size,
          self._global_rank,
          num_workers,
          batch_size or 1,
          drop_last,
          shuffle,
          cache,
      )
  
      self._profile = profile
  
      super().__init__(
          dataset,
          *args,
          batch_sampler=batch_sampler,  # type: ignore
          collate_fn=CacheCollateFn(collate_fn),
          num_workers=num_workers,
          **kwargs,
      )
  
imports: import asyncio
  import inspect
  import logging
  import os
  from importlib import reload
  from typing import Any, Callable, Dict, List, Optional, Union
  import torch
  from torch.utils.data import Dataset, IterableDataset
  from torch.utils.data._utils.collate import default_collate
  from torch.utils.data._utils.fetch import _BaseDatasetFetcher
  from torch.utils.data.dataloader import DataLoader, _BaseDataLoaderIter, _DatasetKind, _MultiProcessingDataLoaderIter, _SingleProcessDataLoaderIter
  from torch.utils.data.sampler import BatchSampler, Sampler
  from lightning.data.streaming import Cache
  from lightning.data.streaming.combined import CombinedStreamingDataset
  from lightning.data.streaming.constants import _DEFAULT_CHUNK_BYTES, _TORCH_GREATER_EQUAL_2_1_0, _VIZ_TRACKER_AVAILABLE
  from lightning.data.streaming.dataset import StreamingDataset
  from lightning.data.streaming.sampler import CacheBatchSampler
  from lightning.data.utilities.env import _DistributedEnv
label_desc: Use image node_id 1 to create a new CacheDataLoader object from inherited base classes: DataLoader with example: obj = CacheDataLoader(dataset)