code: def test_read_csv_head(prepare_data, setup):
      tempdir, pdf = prepare_data
      file_path = os.path.join(tempdir, "test.csv")
      pdf.to_csv(file_path, index=False)
  
      size = os.stat(file_path).st_size / 2
      df1 = md.read_csv(file_path, chunk_bytes=size)
      df2 = df1.head(5)
      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 == 5
      assert len(graph) == 1
      assert opt_df2 in graph.results
  
      result = df2.execute(
          extra_config={"operand_executors": _iloc_operand_executors}
      ).fetch()
      expected = pdf.head(5)
      pd.testing.assert_frame_equal(result, expected)
  
      # test multiple head
      df3 = df1.head(10)
      graph = TileableGraph([df2.data, df3.data])
      next(TileableGraphBuilder(graph).build())
      records = optimize(graph)
      opt_df1 = records.get_optimization_result(df1.data)
      assert opt_df1 is not None
      assert opt_df1.op.nrows == 10
      opt_df2 = records.get_optimization_result(df2.data)
      assert opt_df2 is not None
      assert graph.predecessors(opt_df2)[0] is opt_df1
      assert opt_df2.inputs[0] is opt_df1
      opt_df3 = records.get_optimization_result(df3.data)
      assert opt_df3 is not None
      assert graph.predecessors(opt_df3)[0] is opt_df1
      assert opt_df3.inputs[0] is opt_df1
  
      # test head with successor
      df1 = md.read_csv(file_path, chunk_bytes=size)
      df2 = df1.head(5)
      df3 = df2 + 1
      graph = TileableGraph([df3.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 == 5
      assert len(graph) == 2
  
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 3 for calling a global function with example usage: test_read_csv_head(prepare_data, setup) without return types