class_docstr: User defined function in Python
  
  Notes
  -----
  The constructor of this class is not supposed to be directly called.
  Use :meth:`pyspark.sql.functions.udf` or :meth:`pyspark.sql.functions.pandas_udf`
  to create this instance.
class_docstr_tok: ["User","defined","function","in","Python","Notes","--","--","-","The","constructor","of","this","class","is","not","supposed","to","be","directly","called",".","Use",":","meth",":","`","pyspark.sql.functions.udf","`","or",":","meth",":","`","pyspark.sql.functions.pandas_udf","`","to","create","this","instance","."]
code: def __init__(
      self,
      func: Callable[..., Any],
      returnType: "DataTypeOrString" = StringType(),
      name: Optional[str] = None,
      evalType: int = PythonEvalType.SQL_BATCHED_UDF,
      deterministic: bool = True,
  ):
      if not callable(func):
          raise PySparkTypeError(
              error_class="NOT_CALLABLE",
              message_parameters={
                  "arg_name": "func",
                  "arg_type": type(func).__name__,
              },
          )
  
      if not isinstance(returnType, (DataType, str)):
          raise PySparkTypeError(
              error_class="NOT_DATATYPE_OR_STR",
              message_parameters={
                  "arg_name": "returnType",
                  "arg_type": type(returnType).__name__,
              },
          )
  
      if not isinstance(evalType, int):
          raise PySparkTypeError(
              error_class="NOT_INT",
              message_parameters={
                  "arg_name": "evalType",
                  "arg_type": type(evalType).__name__,
              },
          )
  
      self.func = func
      self.returnType: DataType = (
          UnparsedDataType(returnType)
          if isinstance(returnType, str)
          else returnType
      )
      self._name = name or (
          func.__name__
          if hasattr(func, "__name__")
          else func.__class__.__name__
      )
      self.evalType = evalType
      self.deterministic = deterministic
  
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 to create a new UserDefinedFunction object  with example: obj = UserDefinedFunction(func, returnType, name, evalType, deterministic)