code: def test_map_batches_split(
      ray_start_10_cpus_shared, restore_data_context
  ):
      ds = ray.data.range(1000, parallelism=1).map_batches(
          lambda x: x, batch_size=1000
      )
      assert ds.materialize().num_blocks() == 1
  
      ctx = ray.data.context.DataContext.get_current()
      # 100 integer rows per block.
      ctx.target_max_block_size = 800
  
      ds = ray.data.range(1000, parallelism=1).map_batches(
          lambda x: x, batch_size=1000
      )
      assert ds.materialize().num_blocks() == 10
  
      # A single row is already larger than the target block
      # size.
      ctx.target_max_block_size = 4
      assert ds.materialize().num_blocks() == 1000
  
file_path: ray/python/ray/data/tests/test_splitblocks.py
imports: import numpy
  import pytest
  import ray
  from ray.data._internal.execution.operators.map_transformer import _splitrange
  from ray.data.tests.conftest import *
  from ray.data.tests.conftest import CoreExecutionMetrics, assert_core_execution_metrics_equals, get_initial_core_execution_metrics_snapshot
  from ray.tests.conftest import *
label_desc: Use image node_id 4 for calling a global function with example usage: test_map_batches_split(ray_start_10_cpus_shared, restore_data_context) without return types