code: def test_cache_with_auto_wrapping(tmpdir):
      os.makedirs(os.path.join(tmpdir, "cache_1"), exist_ok=True)
  
      dataset = RandomDataset(64, 64)
      dataloader = CacheDataLoader(
          dataset,
          cache_dir=os.path.join(tmpdir, "cache_1"),
          chunk_bytes=2 << 12,
      )
      for batch in dataloader:
          assert isinstance(batch, torch.Tensor)
      assert sorted(os.listdir(os.path.join(tmpdir, "cache_1"))) == [
          "chunk-0-0.bin",
          "chunk-0-1.bin",
          "index.json",
      ]
      # Your dataset is optimised for the cloud
  
      class RandomDatasetAtRuntime(Dataset):
          def __init__(self, size: int, length: int):
              self.len = length
              self.size = size
  
          def __getitem__(self, index: int) -> torch.Tensor:
              return torch.randn(1, self.size)
  
          def __len__(self) -> int:
              return self.len
  
      os.makedirs(os.path.join(tmpdir, "cache_2"), exist_ok=True)
      dataset = RandomDatasetAtRuntime(64, 64)
      dataloader = CacheDataLoader(
          dataset,
          cache_dir=os.path.join(tmpdir, "cache_2"),
          chunk_bytes=2 << 12,
      )
      with pytest.raises(
          ValueError, match="Your dataset items aren't deterministic"
      ):
          for batch in dataloader:
              pass
  
imports: import json
  import os
  import sys
  from functools import partial
  import numpy
  import pytest
  import torch
  from lightning import seed_everything
  from lightning.data.streaming import Cache
  from lightning.data.streaming.dataloader import CacheDataLoader
  from lightning.data.streaming.dataset import StreamingDataset
  from lightning.data.streaming.item_loader import TokensLoader
  from lightning.data.streaming.serializers import Serializer
  from lightning.data.utilities.env import _DistributedEnv
  from lightning.fabric import Fabric
  from lightning.pytorch.demos.boring_classes import RandomDataset
  from lightning_utilities.core.imports import RequirementCache
  from lightning_utilities.test.warning import no_warning_call
  from torch.utils.data import Dataset
label_desc: Use image node_id 6 for calling a global function with example usage: test_cache_with_auto_wrapping(tmpdir) and returns: torch, self