code: def test_categorical_agg():
      # GH#36327
      values = np.random.default_rng(2).choice([1, 2, None], 30)
      df = pd.DataFrame(
          {
              "x": pd.Categorical(values, categories=[1, 2, 3]),
              "y": range(len(values)),
          }
      )
      gb = df.groupby("x", dropna=False, observed=False)
      result = gb.agg(lambda x: x.sum())
      expected = gb.sum()
      tm.assert_frame_equal(result, expected)
  
imports: import numpy
  import pytest
  from pandas.compat.pyarrow import pa_version_under10p1
  from pandas.core.dtypes.missing import na_value_for_dtype
  import pandas
  import pandas._testing
  from pandas.tests.groupby import get_groupby_method_args
label_desc: Use image node_id 19 for calling a global function with example usage: test_categorical_agg() without return types