code: def test_apply_with_side_effect(self):
      pdf = pd.DataFrame(
          {
              "d": [1.0, 1.0, 1.0, 2.0, 2.0, 2.0],
              "v": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0],
          }
      )
      psdf = ps.from_pandas(pdf)
  
      acc = ps.utils.default_session().sparkContext.accumulator(0)
  
      def sum_with_acc_frame(x) -> ps.DataFrame[np.float64, np.float64]:
          nonlocal acc
          acc += 1
          return np.sum(x)
  
      actual = psdf.groupby("d").apply(sum_with_acc_frame)
      actual.columns = ["d", "v"]
      self.assert_eq(
          actual._to_pandas().sort_index(),
          pdf.groupby("d")
          .apply(sum)
          .sort_index()
          .reset_index(drop=True),
      )
      self.assert_eq(acc.value, 2)
  
      def sum_with_acc_series(x) -> np.float64:
          nonlocal acc
          acc += 1
          return np.sum(x)
  
      self.assert_eq(
          psdf.groupby("d")["v"]
          .apply(sum_with_acc_series)
          ._to_pandas()
          .sort_index(),
          pdf.groupby("d")["v"]
          .apply(sum)
          .sort_index()
          .reset_index(drop=True),
      )
      self.assert_eq(acc.value, 4)
  
imports: import unittest
  import numpy
  import pandas
  from pyspark import pandas
  from pyspark.pandas.config import option_context
  from pyspark.testing.pandasutils import ComparisonTestBase
  from pyspark.testing.sqlutils import SQLTestUtils
label_desc: Use image node_id 9 for calling the GroupbyApplyFuncMixin obj's underlying member method code with example usage: obj.test_apply_with_side_effect() and returns: np, np