code: def q01(lineitem: md.DataFrame):
      date = md.Timestamp("1998-09-02")
      lineitem_filtered = lineitem.loc[
          :,
          [
              "L_QUANTITY",
              "L_EXTENDEDPRICE",
              "L_DISCOUNT",
              "L_TAX",
              "L_RETURNFLAG",
              "L_LINESTATUS",
              "L_SHIPDATE",
              "L_ORDERKEY",
          ],
      ]
      sel = lineitem_filtered.L_SHIPDATE <= date
      lineitem_filtered = lineitem_filtered[sel]
      lineitem_filtered["AVG_QTY"] = lineitem_filtered.L_QUANTITY
      lineitem_filtered["AVG_PRICE"] = lineitem_filtered.L_EXTENDEDPRICE
      lineitem_filtered[
          "DISC_PRICE"
      ] = lineitem_filtered.L_EXTENDEDPRICE * (
          1 - lineitem_filtered.L_DISCOUNT
      )
      lineitem_filtered["CHARGE"] = (
          lineitem_filtered.L_EXTENDEDPRICE
          * (1 - lineitem_filtered.L_DISCOUNT)
          * (1 + lineitem_filtered.L_TAX)
      )
      gb = lineitem_filtered.groupby(
          ["L_RETURNFLAG", "L_LINESTATUS"], as_index=False
      )[
          [
              "L_QUANTITY",
              "L_EXTENDEDPRICE",
              "DISC_PRICE",
              "CHARGE",
              "AVG_QTY",
              "AVG_PRICE",
              "L_DISCOUNT",
              "L_ORDERKEY",
          ]
      ]
      total = gb.agg(
          {
              "L_QUANTITY": "sum",
              "L_EXTENDEDPRICE": "sum",
              "DISC_PRICE": "sum",
              "CHARGE": "sum",
              "AVG_QTY": "mean",
              "AVG_PRICE": "mean",
              "L_DISCOUNT": "mean",
              "L_ORDERKEY": "count",
          }
      )
      # skip sort, Mars groupby enables sort
      # total = total.sort_values(["L_RETURNFLAG", "L_LINESTATUS"])
      print(total.execute())
  
imports: import argparse
  import functools
  import time
  from typing import Callable, List, Optional, Set, Union
  import mars
  import mars.dataframe
label_desc: Use image node_id 10 for calling a global function with example usage: q01(lineitem) without return types