code: def _load_pyfunc(path):
      """
      Load PyFunc implementation. Called by ``pyfunc.load_model``.
  
      :param path: Local filesystem path to the MLflow Model with the ``spark`` flavor.
      """
      from mlflow.utils._spark_utils import (
          _create_local_spark_session_for_loading_spark_model,
          _get_active_spark_session,
      )
  
      model_meta_path = os.path.join(
          os.path.dirname(path), MLMODEL_FILE_NAME
      )
      model_meta = Model.load(model_meta_path)
  
      model_class = model_meta.flavors[FLAVOR_NAME].get("model_class")
      if model_class is not None and model_class.startswith(
          "pyspark.ml.connect."
      ):
          # Note:
          # Spark connect ML models don't require a spark session for running inference.
          spark = None
          spark_model = _load_spark_connect_model(model_class, path)
  
      else:
          # NOTE: The `_create_local_spark_session_for_loading_spark_model()` call below may change
          # settings of the active session which we do not intend to do here.
          # In particular, setting master to local[1] can break distributed clusters.
          # To avoid this problem, we explicitly check for an active session. This is not ideal but
          # there is no good workaround at the moment.
          spark = _get_active_spark_session()
          if spark is None:
              # NB: If there is no existing Spark context, create a new local one.
              # NB: We're disabling caching on the new context since we do not need it and we want to
              # avoid overwriting cache of underlying Spark cluster when executed on a Spark Worker
              # (e.g. as part of spark_udf).
              spark = (
                  _create_local_spark_session_for_loading_spark_model()
              )
  
          spark_model = _load_model(model_uri=path)
  
      return _PyFuncModelWrapper(spark, spark_model)
  
imports: import logging
  import os
  import posixpath
  import re
  import shutil
  from typing import Any, Dict, Optional
  import pandas
  import yaml
  from packaging.version import Version
  import mlflow
  from mlflow import environment_variables, mleap, pyfunc
  from mlflow.environment_variables import MLFLOW_DFS_TMP
  from mlflow.exceptions import MlflowException
  from mlflow.models import Model, ModelInputExample, ModelSignature, infer_signature
  from mlflow.models.model import MLMODEL_FILE_NAME
  from mlflow.models.signature import _LOG_MODEL_INFER_SIGNATURE_WARNING_TEMPLATE
  from mlflow.models.utils import _Example, _save_example
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
  from mlflow.store.artifact.databricks_artifact_repo import DatabricksArtifactRepository
  from mlflow.tracking._model_registry import DEFAULT_AWAIT_MAX_SLEEP_SECONDS
  from mlflow.tracking.artifact_utils import _download_artifact_from_uri, _get_root_uri_and_artifact_path
  from mlflow.utils import _get_fully_qualified_class_name, databricks_utils
  from mlflow.utils.autologging_utils import autologging_integration, safe_patch
  from mlflow.utils.class_utils import _get_class_from_string
  from mlflow.utils.docstring_utils import LOG_MODEL_PARAM_DOCS, format_docstring
  from mlflow.utils.environment import _CONDA_ENV_FILE_NAME, _CONSTRAINTS_FILE_NAME, _PYTHON_ENV_FILE_NAME, _REQUIREMENTS_FILE_NAME, _mlflow_conda_env, _process_conda_env, _process_pip_requirements, _PythonEnv, _validate_env_arguments
  from mlflow.utils.file_utils import TempDir, get_total_file_size, shutil_copytree_without_file_permissions, write_to
  from mlflow.utils.model_utils import _add_code_from_conf_to_system_path, _get_flavor_configuration_from_uri, _validate_and_copy_code_paths
  from mlflow.utils.requirements_utils import _get_pinned_requirement
  from mlflow.utils.uri import append_to_uri_path, dbfs_hdfs_uri_to_fuse_path, generate_tmp_dfs_path, get_databricks_profile_uri_from_artifact_uri, is_databricks_acled_artifacts_uri, is_local_uri, is_valid_dbfs_uri
label_desc: Use image node_id 15 for calling a global function with example usage: _load_pyfunc(path) and returns: _PyFuncModelWrapper