code: def test_batching_pyarrow_table_with_many_chunks():
      """Make sure batching a pyarrow table with many chunks is fast.
  
      See https://github.com/ray-project/ray/issues/31108 for more details.
      """
      num_chunks = 5000
      batch_size = 1024
  
      batches = []
      for _ in range(num_chunks):
          batch = {}
          for i in range(10):
              batch[str(i)] = list(range(batch_size))
          batches.append(pa.Table.from_pydict(batch))
  
      block = pa.concat_tables(batches, promote=True)
  
      start = time.perf_counter()
      batcher = Batcher(batch_size, ensure_copy=False)
      batcher.add(block)
      batcher.done_adding()
      while batcher.has_any():
          batcher.next_batch()
      duration = time.perf_counter() - start
      assert duration < 10
  
      start = time.perf_counter()
      shuffling_batcher = ShufflingBatcher(
          batch_size=batch_size, shuffle_buffer_min_size=batch_size
      )
      shuffling_batcher.add(block)
      shuffling_batcher.done_adding()
      while shuffling_batcher.has_any():
          shuffling_batcher.next_batch()
      duration = time.perf_counter() - start
      assert duration < 30
  
file_path: ray/python/ray/data/tests/test_batcher.py
imports: import time
  import pyarrow
  import pytest
  import ray
  from ray.data._internal.batcher import Batcher, ShufflingBatcher
label_desc: Use image node_id 3 for calling a global function with example usage: test_batching_pyarrow_table_with_many_chunks() without return types