code: def _install_pyfunc_deps(
      model_path=None,
      install_mlflow=False,
      enable_mlserver=False,
      env_manager=em.VIRTUALENV,
  ):
      """
      Creates a conda env for serving the model at the specified path and installs almost all serving
      dependencies into the environment - MLflow is not installed as it's not available via conda.
      """
      # If model is a pyfunc model, create its conda env (even if it also has mleap flavor)
      activate_cmd = []
      if model_path:
          model_config_path = os.path.join(
              model_path, MLMODEL_FILE_NAME
          )
          model = Model.load(model_config_path)
          # NOTE: this differs from _serve cause we always activate the env even if you're serving
          # an mleap model
          if pyfunc.FLAVOR_NAME not in model.flavors:
              return
          conf = model.flavors[pyfunc.FLAVOR_NAME]
          if pyfunc.ENV in conf:
              _logger.info("creating and activating custom environment")
              env = _extract_conda_env(conf[pyfunc.ENV])
              env_path_dst = os.path.join("/opt/mlflow/", env)
              env_path_dst_dir = os.path.dirname(env_path_dst)
              if not os.path.exists(env_path_dst_dir):
                  os.makedirs(env_path_dst_dir)
              shutil.copy2(os.path.join(MODEL_PATH, env), env_path_dst)
              if env_manager == em.CONDA:
                  conda_create_model_env = f"conda env create -n custom_env -f {env_path_dst}"
                  if (
                      Popen(
                          ["bash", "-c", conda_create_model_env]
                      ).wait()
                      != 0
                  ):
                      raise Exception(
                          "Failed to create model environment."
                      )
                  activate_cmd = [
                      "source /miniconda/bin/activate custom_env"
                  ]
              elif env_manager == em.VIRTUALENV:
                  env_activate_cmd = _get_or_create_virtualenv(
                      model_path
                  )
                  path = env_activate_cmd.split(" ")[-1]
                  os.symlink(path, "/opt/activate")
                  activate_cmd = [env_activate_cmd]
  
      # NB: install gunicorn[gevent] from pip rather than from conda because gunicorn is already
      # dependency of mlflow on pip and we expect mlflow to be part of the environment.
      server_deps = ["gunicorn[gevent]"]
      if enable_mlserver:
          server_deps = [
              "'mlserver>=1.2.0,!=1.3.1'",
              "'mlserver-mlflow>=1.2.0,!=1.3.1'",
          ]
  
      install_server_deps = [f"pip install {' '.join(server_deps)}"]
      if (
          Popen(
              [
                  "bash",
                  "-c",
                  " && ".join(activate_cmd + install_server_deps),
              ]
          ).wait()
          != 0
      ):
          raise Exception(
              "Failed to install serving dependencies into the model environment."
          )
  
      if len(activate_cmd) and install_mlflow:
          install_mlflow_cmd = [
              "pip install /opt/mlflow/."
              if _container_includes_mlflow_source()
              else f"pip install mlflow=={MLFLOW_VERSION}"
          ]
          if (
              Popen(
                  [
                      "bash",
                      "-c",
                      " && ".join(activate_cmd + install_mlflow_cmd),
                  ]
              ).wait()
              != 0
          ):
              raise Exception(
                  "Failed to install mlflow into the model environment."
              )
      return activate_cmd
  
imports: import logging
  import multiprocessing
  import os
  import shutil
  import signal
  import sys
  from pathlib import Path
  from subprocess import Popen, check_call
  import mlflow
  import mlflow.version
  from mlflow import mleap, pyfunc
  from mlflow.environment_variables import MLFLOW_DEPLOYMENT_FLAVOR_NAME, MLFLOW_DISABLE_ENV_CREATION
  from mlflow.models import Model
  from mlflow.models.model import MLMODEL_FILE_NAME
  from mlflow.pyfunc import _extract_conda_env, mlserver, scoring_server
  from mlflow.store.artifact.models_artifact_repo import REGISTERED_MODEL_META_FILE_NAME
  from mlflow.utils import env_manager
  from mlflow.utils.file_utils import read_yaml
  from mlflow.utils.virtualenv import _get_or_create_virtualenv
  from mlflow.version import VERSION
label_desc: Use image node_id 3 for calling a global function with example usage: _install_pyfunc_deps(model_path, install_mlflow, enable_mlserver, env_manager) and returns: activate_cmd