code: def test_dataframe_groupby_agg(setup):
      agg_funs = [
          "std",
          "mean",
          "var",
          "max",
          "count",
          "size",
          "all",
          "any",
          "skew",
          "kurt",
          "sem",
          "nunique",
      ]
  
      rs = np.random.RandomState(0)
      raw = pd.DataFrame(
          {
              "c1": np.arange(100).astype(np.int64),
              "c2": rs.choice(["a", "b", "c"], (100,)),
              "c3": rs.rand(100),
          }
      )
      mdf = md.DataFrame(raw, chunk_size=13)
  
      for method in ["tree", "shuffle"]:
          for sort in [True, False]:
              r = mdf.groupby("c2").agg("size", method=method)
              pd.testing.assert_series_equal(
                  r.execute().fetch().sort_index(),
                  raw.groupby("c2").agg("size").sort_index(),
              )
  
              for agg_fun in agg_funs:
                  if agg_fun == "size":
                      continue
                  r = mdf.groupby("c2", sort=sort).agg(
                      agg_fun, method=method
                  )
                  pd.testing.assert_frame_equal(
                      r.execute().fetch().sort_index(),
                      raw.groupby("c2").agg(agg_fun).sort_index(),
                  )
  
              r = mdf.groupby("c2", sort=sort).agg(
                  agg_funs, method=method
              )
              pd.testing.assert_frame_equal(
                  r.execute().fetch().sort_index(),
                  raw.groupby("c2").agg(agg_funs).sort_index(),
              )
  
              agg = OrderedDict(
                  [("c1", ["min", "mean"]), ("c3", "std")]
              )
              r = mdf.groupby("c2", sort=sort).agg(agg, method=method)
              pd.testing.assert_frame_equal(
                  r.execute().fetch().sort_index(),
                  raw.groupby("c2").agg(agg).sort_index(),
              )
  
              agg = OrderedDict([("c1", "min"), ("c3", "sum")])
              r = mdf.groupby("c2", sort=sort).agg(agg, method=method)
              pd.testing.assert_frame_equal(
                  r.execute().fetch().sort_index(),
                  raw.groupby("c2").agg(agg).sort_index(),
              )
  
              r = mdf.groupby("c2", sort=sort).agg(
                  {"c1": "min", "c3": "min"}, method=method
              )
              pd.testing.assert_frame_equal(
                  r.execute().fetch().sort_index(),
                  raw.groupby("c2")
                  .agg({"c1": "min", "c3": "min"})
                  .sort_index(),
              )
  
              r = mdf.groupby("c2", sort=sort).agg(
                  {"c1": "min"}, method=method
              )
              pd.testing.assert_frame_equal(
                  r.execute().fetch().sort_index(),
                  raw.groupby("c2").agg({"c1": "min"}).sort_index(),
              )
  
              # test groupby series
              r = mdf.groupby(mdf["c2"], sort=sort).sum(method=method)
              pd.testing.assert_frame_equal(
                  r.execute().fetch().sort_index(),
                  raw.groupby(raw["c2"]).sum().sort_index(),
              )
  
      r = mdf.groupby("c2").size(method="tree")
      pd.testing.assert_series_equal(
          r.execute().fetch(), raw.groupby("c2").size()
      )
  
      # test inserted kurt method
      r = mdf.groupby("c2").kurtosis(method="tree")
      pd.testing.assert_frame_equal(
          r.execute().fetch(), raw.groupby("c2").kurtosis()
      )
  
      for agg_fun in agg_funs:
          if agg_fun == "size" or callable(agg_fun):
              continue
          r = getattr(mdf.groupby("c2"), agg_fun)(method="tree")
          pd.testing.assert_frame_equal(
              r.execute().fetch(), getattr(raw.groupby("c2"), agg_fun)()
          )
  
      # test as_index=False
      for method in ["tree", "shuffle"]:
          r = mdf.groupby("c2", as_index=False).agg(
              "size", method=method
          )
          if _agg_size_as_frame:
              result = (
                  r.execute()
                  .fetch()
                  .sort_values("c2", ignore_index=True)
              )
              expected = (
                  raw.groupby("c2", as_index=False)
                  .agg("size")
                  .sort_values("c2", ignore_index=True)
              )
              pd.testing.assert_frame_equal(result, expected)
          else:
              result = r.execute().fetch().sort_index()
              expected = (
                  raw.groupby("c2", as_index=False)
                  .agg("size")
                  .sort_index()
              )
              pd.testing.assert_series_equal(result, expected)
  
          r = mdf.groupby("c2", as_index=False).agg(
              "mean", method=method
          )
          pd.testing.assert_frame_equal(
              r.execute().fetch().sort_values("c2", ignore_index=True),
              raw.groupby("c2", as_index=False)
              .agg("mean")
              .sort_values("c2", ignore_index=True),
          )
          assert r.op.groupby_params["as_index"] is False
  
          r = mdf.groupby(["c1", "c2"], as_index=False).agg(
              "mean", method=method
          )
          pd.testing.assert_frame_equal(
              r.execute()
              .fetch()
              .sort_values(["c1", "c2"], ignore_index=True),
              raw.groupby(["c1", "c2"], as_index=False)
              .agg("mean")
              .sort_values(["c1", "c2"], ignore_index=True),
          )
          assert r.op.groupby_params["as_index"] is False
  
      # test as_index=False takes no effect
      r = mdf.groupby(["c1", "c2"], as_index=False).agg(
          ["mean", "count"]
      )
      pd.testing.assert_frame_equal(
          r.execute().fetch(),
          raw.groupby(["c1", "c2"], as_index=False).agg(
              ["mean", "count"]
          ),
      )
      assert r.op.groupby_params["as_index"] is True
  
      r = mdf.groupby("c2").agg(["cumsum", "cumcount"])
      pd.testing.assert_frame_equal(
          r.execute().fetch().sort_index(),
          raw.groupby("c2").agg(["cumsum", "cumcount"]).sort_index(),
      )
  
      r = mdf.groupby("c2").agg(
          sum_c1=md.NamedAgg("c1", "sum"),
          min_c1=md.NamedAgg("c1", "min"),
          mean_c3=md.NamedAgg("c3", "mean"),
          method="tree",
      )
      pd.testing.assert_frame_equal(
          r.execute().fetch(),
          raw.groupby("c2").agg(
              sum_c1=md.NamedAgg("c1", "sum"),
              min_c1=md.NamedAgg("c1", "min"),
              mean_c3=md.NamedAgg("c3", "mean"),
          ),
      )
  
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 3 for calling a global function with example usage: test_dataframe_groupby_agg(setup) without return types