code: def execute_to_legacy_block_list(
      executor: Executor,
      plan: ExecutionPlan,
      allow_clear_input_blocks: bool,
      dataset_uuid: str,
      preserve_order: bool,
  ) -> BlockList:
      """Execute a plan with the new executor and translate it into a legacy block list.
  
      Args:
          executor: The executor to use.
          plan: The legacy plan to execute.
          allow_clear_input_blocks: Whether the executor may consider clearing blocks.
          dataset_uuid: UUID of the dataset for this execution.
          preserve_order: Whether to preserve order in execution.
  
      Returns:
          The output as a legacy block list.
      """
      dag, stats = _get_execution_dag(
          executor,
          plan,
          allow_clear_input_blocks,
          preserve_order,
      )
      bundles = executor.execute(dag, initial_stats=stats)
      block_list = _bundles_to_block_list(bundles)
      # Set the stats UUID after execution finishes.
      _set_stats_uuid_recursive(executor.get_stats(), dataset_uuid)
      return block_list
  
imports: from typing import Iterator, Tuple
  from ray.data._internal.block_list import BlockList
  from ray.data._internal.execution.interfaces import Executor, PhysicalOperator, RefBundle
  from ray.data._internal.lazy_block_list import LazyBlockList
  from ray.data._internal.logical.interfaces.logical_plan import LogicalPlan
  from ray.data._internal.logical.operators.read_operator import Read
  from ray.data._internal.logical.optimizers import get_execution_plan
  from ray.data._internal.logical.rules.set_read_parallelism import compute_additional_split_factor
  from ray.data._internal.logical.util import record_operators_usage
  from ray.data._internal.plan import ExecutionPlan
  from ray.data._internal.planner.plan_read_op import apply_output_blocks_handling_to_read_task
  from ray.data._internal.stats import DatasetStats
  from ray.data.block import Block, BlockMetadata, List
  from ray.data.context import DataContext
  from ray.types import ObjectRef
label_desc: Use image node_id 3 for calling a global function with example usage: execute_to_legacy_block_list(executor, plan, allow_clear_input_blocks, dataset_uuid, preserve_order) and returns: block_list