code: def validate_arguments_and_invoke_function(
      pobj: Union[pd.DataFrame, pd.Series],
      pandas_on_spark_func: Callable,
      pandas_func: Callable,
      input_args: Dict,
  ) -> Any:
      """
      Invokes a pandas function.
  
      This is created because different versions of pandas support different parameters, and as a
      result when we code against the latest version, our users might get a confusing
      "got an unexpected keyword argument" error if they are using an older version of pandas.
  
      This function validates all the arguments, removes the ones that are not supported if they
      are simply the default value (i.e. most likely the user didn't explicitly specify it). It
      throws a TypeError if the user explicitly specifies an argument that is not supported by the
      pandas version available.
  
      For example usage, look at DataFrame.to_html().
  
      :param pobj: the pandas DataFrame or Series to operate on
      :param pandas_on_spark_func: pandas-on-Spark function, used to get default parameter values
      :param pandas_func: pandas function, used to check whether pandas supports all the arguments
      :param input_args: arguments to pass to the pandas function, often created by using locals().
                         Make sure locals() call is at the top of the function so it captures only
                         input parameters, rather than local variables.
      :return: whatever pandas_func returns
      """
      import inspect
  
      # Makes a copy since whatever passed in is likely created by locals(), and we can't delete
      # 'self' key from that.
      args = input_args.copy()
      del args["self"]
  
      if "kwargs" in args:
          # explode kwargs
          kwargs = args["kwargs"]
          del args["kwargs"]
          args = {**args, **kwargs}
  
      pandas_on_spark_params = inspect.signature(
          pandas_on_spark_func
      ).parameters
      pandas_params = inspect.signature(pandas_func).parameters
  
      for param in pandas_on_spark_params.values():
          if param.name not in pandas_params:
              if args[param.name] == param.default:
                  del args[param.name]
              else:
                  raise TypeError(
                      (
                          "The pandas version [%s] available does not support parameter '%s' "
                          + "for function '%s'."
                      )
                      % (
                          pd.__version__,
                          param.name,
                          pandas_func.__name__,
                      )
                  )
  
      args["self"] = pobj
      return pandas_func(**args)
  
imports: import functools
  from contextlib import contextmanager
  import os
  from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, TYPE_CHECKING, cast, no_type_check, overload
  import warnings
  import pandas
  from pandas.api.types import is_list_like
  from pyspark.sql import functions, Column, DataFrame, SparkSession
  from pyspark.sql.types import DoubleType
  from pyspark.sql.utils import is_remote, get_dataframe_class
  from pyspark.errors import PySparkTypeError
  from pyspark import pandas
  from pyspark.pandas._typing import Axis, Label, Name, DataFrameOrSeries
  from pyspark.pandas.typedef.typehints import as_spark_type
label_desc: Use image node_id 7 for calling a global function with example usage: validate_arguments_and_invoke_function(pobj, pandas_on_spark_func, pandas_func, input_args) and returns: pandas_func