code: def __test_merge(
      self,
      left=None,
      right=None,
      by=["id"],
      fn=lambda lft, rgt: pd.merge(lft, rgt, on=["id", "k"]),
      output_schema="id long, k int, v int, v2 int",
      expected=None,
  ):
      # Test fn as is, cf. _test_merge
      left = self.data1 if left is None else left
      right = self.data2 if right is None else right
  
      result = (
          left.groupby(*by)
          .cogroup(right.groupby(*by))
          .applyInPandas(fn, output_schema)
          .sort(["id", "k"])
          .toPandas()
      )
  
      left = left.toPandas()
      right = right.toPandas()
  
      expected = (
          pd.merge(left, right, on=["id", "k"]).sort_values(
              by=["id", "k"]
          )
          if expected is None
          else expected
      )
  
      assert_frame_equal(expected, result)
  
imports: import unittest
  from typing import cast
  from pyspark.sql.functions import array, explode, col, lit, udf, pandas_udf, sum
  from pyspark.sql.types import ArrayType, DoubleType, LongType, StructType, StructField, YearMonthIntervalType, Row
  from pyspark.sql.window import Window
  from pyspark.errors import IllegalArgumentException, PythonException
  from pyspark.testing.sqlutils import ReusedSQLTestCase, have_pandas, have_pyarrow, pandas_requirement_message, pyarrow_requirement_message
  from pyspark.testing.utils import QuietTest
label_desc: Use image node_id 41 for calling the CogroupedApplyInPandasTestsMixin obj's underlying member method code with example usage: obj.__test_merge(left, right, by, fn, output_schema, expected) without return types