code: def _wrap_function(
      sc: SparkContext,
      func: Callable[..., Any],
      returnType: Optional[DataType] = None,
  ) -> JavaObject:
      command: Any
      if returnType is None:
          command = func
      else:
          command = (func, returnType)
      (
          pickled_command,
          broadcast_vars,
          env,
          includes,
      ) = _prepare_for_python_RDD(sc, command)
      assert sc._jvm is not None
      return sc._jvm.SimplePythonFunction(
          bytearray(pickled_command),
          env,
          includes,
          sc.pythonExec,
          sc.pythonVer,
          broadcast_vars,
          sc._javaAccumulator,
      )
  
imports: from inspect import getfullargspec
  import functools
  import inspect
  import sys
  import warnings
  from typing import Callable, Any, TYPE_CHECKING, Optional, cast, Union
  from py4j.java_gateway import JavaObject
  from pyspark import SparkContext
  from pyspark.rdd import _prepare_for_python_RDD, PythonEvalType
  from pyspark.sql.column import Column, _to_java_expr, _to_seq
  from pyspark.sql.types import DataType, StringType, StructType, _parse_datatype_string
  from pyspark.sql.utils import get_active_spark_context
  from pyspark.sql.pandas.types import to_arrow_type
  from pyspark.sql.pandas.utils import require_minimum_pandas_version, require_minimum_pyarrow_version
  from pyspark.errors import PySparkTypeError, PySparkNotImplementedError, PySparkRuntimeError
label_desc: Use image node_id 1 for calling a global function with example usage: _wrap_function(sc, func, returnType) and returns: sc