code: def test_named_arguments_and_defaults(self):
      df = self.data
  
      @pandas_udf("double", PandasUDFType.GROUPED_AGG)
      def biased_sum(v, w=None):
          return v.sum() + (w.sum() if w is not None else 100)
  
      with self.tempView("v"):
          df.createOrReplaceTempView("v")
          self.spark.udf.register("biased_sum", biased_sum)
  
          # without "w"
          for i, aggregated in enumerate(
              [
                  df.groupby("id").agg(biased_sum(df.v).alias("s")),
                  df.groupby("id").agg(biased_sum(v=df.v).alias("s")),
                  self.spark.sql(
                      "SELECT id, biased_sum(v) as s FROM v GROUP BY id"
                  ),
                  self.spark.sql(
                      "SELECT id, biased_sum(v => v) as s FROM v GROUP BY id"
                  ),
              ]
          ):
              with self.subTest(with_w=False, query_no=i):
                  assertDataFrameEqual(
                      aggregated,
                      df.groupby("id").agg(
                          (sum(df.v) + lit(100)).alias("s")
                      ),
                  )
  
          # with "w"
          for i, aggregated in enumerate(
              [
                  df.groupby("id").agg(
                      biased_sum(df.v, w=df.w).alias("s")
                  ),
                  df.groupby("id").agg(
                      biased_sum(v=df.v, w=df.w).alias("s")
                  ),
                  df.groupby("id").agg(
                      biased_sum(w=df.w, v=df.v).alias("s")
                  ),
                  self.spark.sql(
                      "SELECT id, biased_sum(v, w => w) as s FROM v GROUP BY id"
                  ),
                  self.spark.sql(
                      "SELECT id, biased_sum(v => v, w => w) as s FROM v GROUP BY id"
                  ),
                  self.spark.sql(
                      "SELECT id, biased_sum(w => w, v => v) as s FROM v GROUP BY id"
                  ),
              ]
          ):
              with self.subTest(with_w=True, query_no=i):
                  assertDataFrameEqual(
                      aggregated,
                      df.groupby("id").agg(
                          (sum(df.v) + sum(df.w)).alias("s")
                      ),
                  )
  
imports: import unittest
  from typing import cast
  from pyspark.rdd import PythonEvalType
  from pyspark.sql import Row
  from pyspark.sql.functions import array, explode, col, lit, mean, sum, udf, pandas_udf, PandasUDFType
  from pyspark.sql.types import ArrayType, YearMonthIntervalType
  from pyspark.errors import AnalysisException, PySparkNotImplementedError, PythonException
  from pyspark.testing.sqlutils import ReusedSQLTestCase, have_pandas, have_pyarrow, pandas_requirement_message, pyarrow_requirement_message
  from pyspark.testing.utils import QuietTest, assertDataFrameEqual
label_desc: Use image node_id 28 for calling the GroupedAggPandasUDFTestsMixin obj's underlying member method code with example usage: obj.test_named_arguments_and_defaults() and returns: unknown