code: def test_binary_writer_with_ints_and_chunk_bytes(tmpdir):
      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_bytes=90)
  
      for i in range(100):
          binary_writer[i] = {"i": i, "i+1": i + 1, "i+2": i + 2}
  
      assert len(os.listdir(tmpdir)) == 19
      binary_writer.done()
      binary_writer.merge()
      assert len(os.listdir(tmpdir)) == 21
  
      with open(os.path.join(tmpdir, "index.json")) as f:
          data = json.load(f)
  
      assert data["chunks"][0]["chunk_size"] == 6
      assert data["chunks"][1]["chunk_size"] == 5
      assert data["chunks"][-1]["chunk_size"] == 4
  
      chunk_sizes = np.cumsum(
          [chunk["chunk_size"] for chunk in data["chunks"]]
      )
  
      reader = BinaryReader(tmpdir, max_cache_size=10 ^ 9)
      for i in range(100):
          for chunk_index, chunk_start in enumerate(chunk_sizes):
              if i >= chunk_start:
                  continue
              break
          data = reader.read(ChunkedIndex(i, chunk_index=chunk_index))
          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 1 for calling a global function with example usage: test_binary_writer_with_ints_and_chunk_bytes(tmpdir) without return types