code: def test_sort_head(prepare_data, setup):
      _, pdf = prepare_data
  
      df1 = md.DataFrame(pdf, chunk_size=20)
      df1 = df1.sort_values(by="b")
      df2 = df1.head(10)
      graph = TileableGraph([df2.data])
      next(TileableGraphBuilder(graph).build())
      records = optimize(graph)
      assert records.get_optimization_result(df1.data) is None
      opt_df2 = records.get_optimization_result(df2.data)
      assert opt_df2.op.nrows == 10
      assert len(graph) == 2
      assert opt_df2 in graph.results
  
      result = df2.execute(
          extra_config={"operand_executors": _iloc_operand_executors}
      ).fetch()
      expected = pdf.sort_values(by="b").head(10)
      pd.testing.assert_frame_equal(result, expected)
  
      pdf2 = pdf.copy()
      pdf2.set_index("b", inplace=True)
      df1 = md.DataFrame(pdf2, chunk_size=20)
      df1 = df1.sort_index()
      df2 = df1.head(10)
      graph = TileableGraph([df2.data])
      next(TileableGraphBuilder(graph).build())
      records = optimize(graph)
      assert records.get_optimization_result(df1.data) is None
      opt_df2 = records.get_optimization_result(df2.data)
      assert opt_df2.op.nrows == 10
      assert len(graph) == 2
      assert opt_df2 in graph.results
  
      result = df2.execute(
          extra_config={"operand_executors": _iloc_operand_executors}
      ).fetch()
      expected = pdf2.sort_index().head(10)
      pd.testing.assert_frame_equal(result, expected)
  
file_path: mars/mars/optimization/logical/tileable/tests/test_head.py
imports: import os
  import tempfile
  import pandas
  import numpy
  import pytest
  from .....None import dataframe
  from .....core import TileableGraph, TileableGraphBuilder, enter_mode
  from .....dataframe.indexing.iloc import DataFrameIlocGetItem, SeriesIlocGetItem
  from ..None import optimize
label_desc: Use image node_id 5 for calling a global function with example usage: test_sort_head(prepare_data, setup) without return types