code: def head(groupby, n=5):
      """
      Return first n rows of each group.
  
      Similar to ``.apply(lambda x: x.head(n))``, but it returns a subset of rows
      from the original Series or DataFrame with original index and order preserved
      (``as_index`` flag is ignored).
  
      Does not work for negative values of `n`.
  
      Returns
      -------
      Series or DataFrame
  
      See Also
      --------
      Series.groupby
      DataFrame.groupby
  
      Examples
      --------
  
      >>> import mars.dataframe as md
      >>> df = md.DataFrame([[1, 2], [1, 4], [5, 6]],
      ...                   columns=['A', 'B'])
      >>> df.groupby('A').head(1).execute()
         A  B
      0  1  2
      2  5  6
      >>> df.groupby('A').head(-1).execute()
      Empty DataFrame
      Columns: [A, B]
      Index: []
      """
      groupby_params = groupby.op.groupby_params.copy()
      groupby_params.pop("as_index", None)
  
      op = GroupByHead(
          row_count=n,
          groupby_params=groupby_params,
          enable_negative=_pandas_enable_negative,
      )
      return op(groupby)
  
file_path: mars/mars/dataframe/groupby/head.py
imports: import numpy
  import pandas
  from ...None import opcodes
  from ...core import OutputType, get_output_types, recursive_tile
  from ...serialization.serializables import DictField, Int64Field, BoolField
  from ...utils import pd_release_version
  from ..core import IndexValue
  from ..operands import DataFrameOperandMixin, DataFrameOperand
  from ..utils import build_concatenated_rows_frame, parse_index
label_desc: Use image node_id 1 for calling a global function with example usage: head(groupby, n) and returns: op