code: def test_cache_for_text_tokens(tmpdir):
      seed_everything(42)
  
      block_size = 1024 + 1
      cache = Cache(
          input_dir=str(tmpdir),
          chunk_size=block_size * 11,
          item_loader=TokensLoader(block_size),
      )
      text_idxs_list = []
  
      counter = 0
      while True:
          text_ids = torch.randint(
              0, 1000, (np.random.randint(0, 1000),)
          ).to(torch.int)
          text_idxs_list.append(text_ids)
          chunk_filepath = cache._add_item(counter, text_ids)
          if chunk_filepath:
              break
          counter += 1
  
      cache.done()
      cache.merge()
  
      assert len(cache) == 10
  
      cache_0 = cache[0]
      cache_1 = cache[1]
      assert len(cache_0) == block_size
      assert len(cache_1) == block_size
      assert not torch.equal(cache_0, cache[1])
      indices = torch.cat(text_idxs_list, dim=0)
      assert torch.equal(cache_0, indices[: len(cache_0)])
      assert torch.equal(
          cache_1, indices[len(cache_0) : len(cache_0) + len(cache_1)]
      )
  
      with pytest.raises(ValueError, match="TokensLoader"):
          len(Cache(str(tmpdir), chunk_size=block_size * 11))
  
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 10 for calling a global function with example usage: test_cache_for_text_tokens(tmpdir) without return types