code: def test_binary_writer_with_ints_and_chunk_size(tmpdir):
      seed_everything(42)
  
      with pytest.raises(
          FileNotFoundError,
          match="The provided cache directory `dontexists` doesn't exist.",
      ):
          BinaryWriter("dontexists", {})
  
      with pytest.raises(
          ValueError, match="No compresion algorithms are installed."
      ):
          BinaryWriter(
              tmpdir, {"i": "int"}, compression="something_else"
          )
  
      binary_writer = BinaryWriter(tmpdir, chunk_size=25)
  
      indices = list(range(100))
      indices = (
          indices[:5] + np.random.permutation(indices[5:]).tolist()
      )
  
      for i in indices:
          binary_writer[i] = {"i": i, "i+1": i + 1, "i+2": i + 2}
  
      assert len(os.listdir(tmpdir)) >= 2
      binary_writer.done()
      binary_writer.merge()
      assert len(os.listdir(tmpdir)) == 5
  
      with open(os.path.join(tmpdir, "index.json")) as f:
          data = json.load(f)
  
      assert data["chunks"][0]["chunk_size"] == 25
      assert data["chunks"][1]["chunk_size"] == 25
      assert data["chunks"][-1]["chunk_size"] == 25
  
      reader = BinaryReader(tmpdir, max_cache_size=10 ^ 9)
      for i in range(100):
          data = reader.read(ChunkedIndex(i, chunk_index=i // 25))
          assert data == {"i": i, "i+1": i + 1, "i+2": i + 2}
  
file_path: pytorch-lightning/tests/tests_data/streaming/test_writer.py
imports: import json
  import os
  import sys
  import numpy
  import pytest
  from lightning import seed_everything
  from lightning.data.streaming.reader import BinaryReader
  from lightning.data.streaming.sampler import ChunkedIndex
  from lightning.data.streaming.writer import BinaryWriter
  from lightning.data.utilities.format import _FORMAT_TO_RATIO
  from lightning_utilities.core.imports import RequirementCache
label_desc: Use image node_id 2 for calling a global function with example usage: test_binary_writer_with_ints_and_chunk_size(tmpdir) without return types