code: def test_groupby_head(setup):
      df1 = pd.DataFrame(
          {
              "a": [3, 5, 2, 7, 1, 2, 4, 6, 2, 4],
              "b": [8, 3, 4, 1, 8, 2, 2, 2, 2, 3],
              "c": [1, 8, 8, 5, 3, 5, 0, 0, 5, 4],
              "d": [9, 7, 6, 3, 6, 3, 2, 1, 5, 8],
          }
      )
      # test single chunk
      mdf = md.DataFrame(df1)
  
      r = mdf.groupby("b").head(1)
      pd.testing.assert_frame_equal(
          r.execute().fetch().sort_index(), df1.groupby("b").head(1)
      )
      r = mdf.groupby("b").head(-1)
      pd.testing.assert_frame_equal(
          r.execute().fetch().sort_index(), df1.groupby("b").head(-1)
      )
      r = mdf.groupby("b")["a", "c"].head(1)
      pd.testing.assert_frame_equal(
          r.execute().fetch().sort_index(),
          df1.groupby("b")["a", "c"].head(1),
      )
  
      # test multiple chunks
      mdf = md.DataFrame(df1, chunk_size=3)
  
      r = mdf.groupby("b").head(1)
      pd.testing.assert_frame_equal(
          r.execute().fetch().sort_index(), df1.groupby("b").head(1)
      )
  
      r = mdf.groupby("b").head(-1)
      pd.testing.assert_frame_equal(
          r.execute().fetch().sort_index(), df1.groupby("b").head(-1)
      )
  
      # test head with selection
      r = mdf.groupby("b")["a", "d"].head(1)
      pd.testing.assert_frame_equal(
          r.execute().fetch().sort_index(),
          df1.groupby("b")["a", "d"].head(1),
      )
      r = mdf.groupby("b")["c", "a", "d"].head(1)
      pd.testing.assert_frame_equal(
          r.execute().fetch().sort_index(),
          df1.groupby("b")["c", "a", "d"].head(1),
      )
      r = mdf.groupby("b")["c"].head(1)
      pd.testing.assert_series_equal(
          r.execute().fetch().sort_index(),
          df1.groupby("b")["c"].head(1),
      )
  
      # test single chunk
      series1 = pd.Series([3, 4, 5, 3, 5, 4, 1, 2, 3])
      ms = md.Series(series1)
  
      r = ms.groupby(lambda x: x % 2).head(1)
      pd.testing.assert_series_equal(
          r.execute().fetch().sort_index(),
          series1.groupby(lambda x: x % 2).head(1),
      )
      r = ms.groupby(lambda x: x % 2).head(-1)
      pd.testing.assert_series_equal(
          r.execute().fetch().sort_index(),
          series1.groupby(lambda x: x % 2).head(-1),
      )
  
      # test multiple chunk
      ms = md.Series(series1, chunk_size=3)
  
      r = ms.groupby(lambda x: x % 2).head(1)
      pd.testing.assert_series_equal(
          r.execute().fetch().sort_index(),
          series1.groupby(lambda x: x % 2).head(1),
      )
  
      # test with special index
      series1 = pd.Series(
          [3, 4, 5, 3, 5, 4, 1, 2, 3], index=[4, 1, 2, 3, 5, 8, 6, 7, 9]
      )
      ms = md.Series(series1, chunk_size=3)
  
      r = ms.groupby(lambda x: x % 2).head(1)
      pd.testing.assert_series_equal(
          r.execute().fetch().sort_index(),
          series1.groupby(lambda x: x % 2).head(1).sort_index(),
      )
  
imports: from collections import OrderedDict
  import numpy
  import pandas
  import pytest
  from ....None import dataframe
  from ....config import option_context
  from ....core.operand import OperandStage
  from ....tests.core import assert_groupby_equal, require_cudf
  from ....utils import arrow_array_to_objects, pd_release_version
  from ...core import DATAFRAME_OR_SERIES_TYPE
  from ..aggregation import DataFrameGroupByAgg
label_desc: Use image node_id 16 for calling a global function with example usage: test_groupby_head(setup) without return types