code: def test_prepare_chunks_thread_eviction(tmpdir, monkeypatch):
      monkeypatch.setattr(reader, "_LONG_DEFAULT_TIMEOUT", 0.1)
  
      cache_dir = os.path.join(tmpdir, "cache_dir")
      os.makedirs(cache_dir, exist_ok=True)
      cache = Cache(
          input_dir=cache_dir, chunk_size=2, max_cache_size=28020
      )
  
      for i in range(25):
          cache[i] = i
  
      cache.done()
      cache.merge()
  
      cache._reader._try_load_config()
  
      assert len(os.listdir(cache_dir)) == 14
  
      thread = PrepareChunksThread(
          cache._reader.config,
          item_loader=PyTreeLoader(),
          max_cache_size=10000,
      )
      assert not thread._delete_chunks_when_processed
  
      thread = PrepareChunksThread(
          cache._reader.config,
          item_loader=PyTreeLoader(),
          max_cache_size=1,
      )
      assert thread._delete_chunks_when_processed
  
      thread.start()
  
      assert thread._pre_download_counter == 0
  
      thread.download([0, 1, 2, 3, 4, 5, _END_TOKEN])
  
      while thread._pre_download_counter == 0:
          sleep(0.01)
  
      assert not thread._has_exited
  
      for i in range(5):
          thread.delete([i])
          while len(os.listdir(cache_dir)) != 14 - (i + 1):
              sleep(0.01)
  
      assert thread._pre_download_counter <= 2
  
      assert len(os.listdir(cache_dir)) == 9
      assert thread._has_exited
      thread.join()
  
file_path: pytorch-lightning/tests/tests_data/streaming/test_reader.py
imports: import os
  import shutil
  from time import sleep
  import numpy
  from lightning.data.streaming import reader
  from lightning.data.streaming.cache import Cache
  from lightning.data.streaming.config import ChunkedIndex
  from lightning.data.streaming.item_loader import PyTreeLoader
  from lightning.data.streaming.reader import _END_TOKEN, PrepareChunksThread, _get_folder_size
  from lightning_cloud.resolver import Dir
label_desc: Use image node_id 3 for calling a global function with example usage: test_prepare_chunks_thread_eviction(tmpdir, monkeypatch) without return types