code: def save_model(
      model,
      path,
      conda_env=None,
      code_paths=None,
      mlflow_model=None,
      signature: ModelSignature = None,
      input_example: ModelInputExample = None,
      pip_requirements=None,
      extra_pip_requirements=None,
      metadata=None,
      model_config: Optional[Dict[str, Any]] = None,
  ):
      """
      Save a Promptflow model to a path on the local file system.
  
      :param model: A promptflow model loaded by `promptflow.load_flow()`.
      :param path: Local path where the serialized model (as YAML) is to be saved.
      :param conda_env: {{ conda_env }}
      :param code_paths: A list of local filesystem paths to Python file dependencies (or directories
                         containing file dependencies). These files are *prepended* to the system
                         path when the model is loaded.
      :param mlflow_model: :py:mod:`mlflow.models.Model` this flavor is being added to.
      :param signature: :py:class:`ModelSignature <mlflow.models.ModelSignature>`
                        describes model input and output
                        :py:class:`Schema <mlflow.types.Schema>`.
  
      :param input_example: {{ input_example }}
      :param pip_requirements: {{ pip_requirements }}
      :param extra_pip_requirements: {{ extra_pip_requirements }}
      :param metadata: Custom metadata dictionary passed to the model and stored in the MLmodel file.
  
                       .. Note:: Experimental: This parameter may change or be removed in a future
                                               release without warning.
      :param model_config:
          A dict of valid overrides that can be applied to a flow instance during inference.
          These arguments are used exclusively for the case of loading the model as a ``pyfunc``
          Model.
          These values are not applied to a returned flow from a call to
          ``mlflow.promptflow.load_model()``.
          To override configs for a loaded flow with promptflow flavor,
          please update the ``pf_model.context`` directly.
  
  
          Configs that can be overridden includes:
          ``connection.provider`` - The connection provider to use for the flow. Reach
          https://microsoft.github.io/promptflow/how-to-guides/set-global-configs.html#connection-provider
          for more details on how to set connection provider.
  
  
          An example of providing overrides for a model to use azure machine
          learning workspace connection:
  
          .. code-block:: python
  
              flow_folder = Path(__file__).parent / "basic"
              flow = load_flow(flow_folder)
  
              workspace_resource_id = (
                  "azureml://subscriptions/{your-subscription}/resourceGroups/{your-resourcegroup}"
                  "/providers/Microsoft.MachineLearningServices/workspaces/{your-workspace}"
              )
              model_config = {"connection.provider": workspace_resource_id}
  
              with mlflow.start_run():
                  logged_model = mlflow.promptflow.log_model(
                      flow, artifact_path="promptflow_model", model_config=model_config
                  )
      """
      import promptflow
      from promptflow._sdk._mlflow import (
          DAG_FILE_NAME,
          Flow,
          _merge_local_code_and_additional_includes,
          remove_additional_includes,
      )
  
      _validate_env_arguments(
          conda_env, pip_requirements, extra_pip_requirements
      )
  
      if (
          not isinstance(model, Flow)
          or not hasattr(model, "flow_dag_path")
          or not hasattr(model, "code")
      ):
          raise mlflow.MlflowException.invalid_parameter_value(
              _UNSUPPORTED_MODEL_ERROR_MESSAGE.format(
                  instance_type=type(model).__name__
              )
          )
  
      # check if path exists
      path = os.path.abspath(path)
      _validate_and_prepare_target_save_path(path)
  
      code_dir_subpath = _validate_and_copy_code_paths(code_paths, path)
  
      model_flow_path = os.path.join(path, _MODEL_FLOW_DIRECTORY)
  
      # Resolve additional includes in flow
      with _merge_local_code_and_additional_includes(
          code_path=model.code
      ) as resolved_model_dir:
          remove_additional_includes(Path(resolved_model_dir))
          shutil.copytree(src=resolved_model_dir, dst=model_flow_path)
      # Get flow env in flow dag
      flow_env = _resolve_env_from_flow(model.flow_dag_path)
  
      if signature is None and input_example is not None:
          wrapped_model = _PromptflowModelWrapper(model)
          signature = _infer_signature_from_input_example(
              input_example, wrapped_model
          )
  
      if mlflow_model is None:
          mlflow_model = Model()
      if signature is not None:
          mlflow_model.signature = signature
  
      if input_example is not None:
          _save_example(mlflow_model, input_example, path)
      if metadata is not None:
          mlflow_model.metadata = metadata
  
      # update flavor info to mlflow_model
      mlflow_model.add_flavor(
          FLAVOR_NAME,
          code=code_dir_subpath,
          version=promptflow.__version__,
          entry=f"{_MODEL_FLOW_DIRECTORY}/{DAG_FILE_NAME}",
          **flow_env,
      )
  
      # append loader_module, data and env data to mlflow_model
      pyfunc.add_to_model(
          mlflow_model,
          loader_module="mlflow.promptflow",
          conda_env=_CONDA_ENV_FILE_NAME,
          python_env=_PYTHON_ENV_FILE_NAME,
          code=code_dir_subpath,
          model_config=model_config,
      )
  
      # save mlflow_model to path/MLmodel
      mlflow_model.save(os.path.join(path, MLMODEL_FILE_NAME))
  
      if conda_env is None:
          if pip_requirements is None:
              default_reqs = get_default_pip_requirements()
              inferred_reqs = mlflow.models.infer_pip_requirements(
                  path, FLAVOR_NAME, fallback=default_reqs
              )
              default_reqs = sorted(
                  set(inferred_reqs).union(default_reqs)
              )
          else:
              default_reqs = None
          (
              conda_env,
              pip_requirements,
              pip_constraints,
          ) = _process_pip_requirements(
              default_reqs,
              pip_requirements,
              extra_pip_requirements,
          )
      else:
          (
              conda_env,
              pip_requirements,
              pip_constraints,
          ) = _process_conda_env(conda_env)
  
      with open(os.path.join(path, _CONDA_ENV_FILE_NAME), "w") as f:
          yaml.safe_dump(conda_env, stream=f, default_flow_style=False)
  
      # Save `constraints.txt` if necessary
      if pip_constraints:
          write_to(
              os.path.join(path, _CONSTRAINTS_FILE_NAME),
              "\n".join(pip_constraints),
          )
  
      # Save `requirements.txt`
      write_to(
          os.path.join(path, _REQUIREMENTS_FILE_NAME),
          "\n".join(pip_requirements),
      )
  
      _PythonEnv.current().to_yaml(
          os.path.join(path, _PYTHON_ENV_FILE_NAME)
      )
  
imports: import logging
  import os
  import shutil
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Union
  import pandas
  import yaml
  import mlflow
  from mlflow import pyfunc
  from mlflow.models import Model, ModelSignature
  from mlflow.models.model import MLMODEL_FILE_NAME
  from mlflow.models.signature import _infer_signature_from_input_example
  from mlflow.models.utils import ModelInputExample, _save_example
  from mlflow.tracking._model_registry import DEFAULT_AWAIT_MAX_SLEEP_SECONDS
  from mlflow.tracking.artifact_utils import _download_artifact_from_uri
  from mlflow.utils.annotations import experimental
  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 write_to
  from mlflow.utils.model_utils import _validate_and_copy_code_paths, _validate_and_prepare_target_save_path
  from mlflow.utils.requirements_utils import _get_pinned_requirement
label_desc: Use image node_id 4 for calling a global function with example usage: save_model(model, path, conda_env, code_paths, mlflow_model, signature, input_example, pip_requirements, extra_pip_requirements, metadata, model_config) without return types