code: def test_binary_writer_with_jpeg_and_png(tmpdir):
      from PIL import Image
  
      cache_dir = os.path.join(tmpdir, "chunks")
      os.makedirs(cache_dir, exist_ok=True)
      binary_writer = BinaryWriter(cache_dir, chunk_bytes=2 << 12)
  
      np_data = np.random.randint(255, size=(28, 28), dtype=np.uint8)
      img = Image.fromarray(np_data).convert("L")
      path = os.path.join(tmpdir, "img.jpeg")
      img.save(path, format="jpeg", quality=100)
      img_jpeg = Image.open(path)
  
      binary_writer[0] = {"x": img_jpeg, "y": 0}
      binary_writer[1] = {"x": img, "y": 1}
  
      with pytest.raises(
          ValueError, match="The data format changed between items"
      ):
          binary_writer[2] = {"x": 2, "y": 1}
  
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 5 for calling a global function with example usage: test_binary_writer_with_jpeg_and_png(tmpdir) without return types