code: def test_randomize_block_order_after_repartition():
      read = get_parquet_read_logical_op()
      operator1 = RandomizeBlocks(input_op=read)
      operator2 = Repartition(
          input_op=operator1, num_outputs=1, shuffle=False
      )
      operator3 = RandomizeBlocks(input_op=operator2)
      operator4 = RandomizeBlocks(input_op=operator3)
      operator5 = MapBatches(input_op=operator4, fn=lambda x: x)
      operator6 = Repartition(
          input_op=operator5, num_outputs=1, shuffle=False
      )
      original_plan = LogicalPlan(dag=operator6)
  
      rule = ReorderRandomizeBlocksRule()
      optimized_plan = rule.apply(original_plan)
  
      assert isinstance(optimized_plan.dag, Repartition)
      assert isinstance(
          optimized_plan.dag.input_dependencies[0], RandomizeBlocks
      )
  
      # Check that multiple RandomizeBlocks operators are deduped within repartition
      # boundaries.
      operator_count = 0
      for _ in optimized_plan.dag.post_order_iter():
          operator_count += 1
  
      # Read -> RandomizeBlocks -> Repartition -> MapBatches -> RandomizeBlocks ->
      # Repartition
      assert operator_count == 6
  
file_path: ray/python/ray/data/tests/test_randomize_block_order.py
imports: import pytest
  import ray
  from ray.data._internal.execution.operators.base_physical_operator import AllToAllOperator
  from ray.data._internal.execution.operators.map_operator import MapOperator
  from ray.data._internal.logical.interfaces import LogicalPlan
  from ray.data._internal.logical.operators.all_to_all_operator import RandomizeBlocks, Repartition
  from ray.data._internal.logical.operators.map_operator import AbstractUDFMap, MapBatches
  from ray.data._internal.logical.operators.read_operator import Read
  from ray.data._internal.logical.optimizers import LogicalOptimizer
  from ray.data._internal.logical.rules.randomize_blocks import ReorderRandomizeBlocksRule
  from ray.data._internal.planner.planner import Planner
  from ray.data.tests.test_util import get_parquet_read_logical_op
  from ray.data.tests.util import extract_values
label_desc: Use image node_id 4 for calling a global function with example usage: test_randomize_block_order_after_repartition() without return types