code: def _create_py_udf(
      f: Callable[..., Any],
      returnType: "DataTypeOrString",
      useArrow: Optional[bool] = None,
  ) -> "UserDefinedFunctionLike":
      if useArrow is None:
          is_arrow_enabled = False
          try:
              from pyspark.sql.connect.session import SparkSession
  
              session = SparkSession.active()
              is_arrow_enabled = (
                  str(
                      session.conf.get(
                          "spark.sql.execution.pythonUDF.arrow.enabled"
                      )
                  ).lower()
                  == "true"
              )
          except PySparkRuntimeError as e:
              if e.getErrorClass() == "NO_ACTIVE_OR_DEFAULT_SESSION":
                  pass  # Just uses the default if no session found.
              else:
                  raise e
      else:
          is_arrow_enabled = useArrow
  
      eval_type: int = PythonEvalType.SQL_BATCHED_UDF
  
      if is_arrow_enabled:
          try:
              is_func_with_args = len(getfullargspec(f).args) > 0
          except TypeError:
              is_func_with_args = False
          if is_func_with_args:
              eval_type = PythonEvalType.SQL_ARROW_BATCHED_UDF
          else:
              warnings.warn(
                  "Arrow optimization for Python UDFs cannot be enabled.",
                  UserWarning,
              )
  
      return _create_udf(f, returnType, eval_type)
  
imports: from pyspark.sql.connect.utils import check_dependencies
  import sys
  import functools
  import warnings
  from inspect import getfullargspec
  from typing import cast, Callable, Any, List, TYPE_CHECKING, Optional, Union
  from pyspark.rdd import PythonEvalType
  from pyspark.sql.connect.expressions import ColumnReference, CommonInlineUserDefinedFunction, Expression, NamedArgumentExpression, PythonUDF
  from pyspark.sql.connect.column import Column
  from pyspark.sql.connect.types import UnparsedDataType
  from pyspark.sql.types import DataType, StringType
  from pyspark.sql.udf import UDFRegistration
  from pyspark.errors import PySparkTypeError, PySparkRuntimeError
label_desc: Use image node_id 1 for calling a global function with example usage: _create_py_udf(f, returnType, useArrow) and returns: _create_udf