code: def save_model(
      ludwig_model,
      path,
      conda_env=None,
      mlflow_model=None,
      signature: ModelSignature = None,
      input_example: ModelInputExample = None,
  ):
      """Save a Ludwig model to a path on the local file system.
  
      :param ludwig_model: Ludwig model (an instance of `ludwig.api.LudwigModel`_) to be saved.
      :param path: Local path where the model is to be saved.
      :param conda_env: Either a dictionary representation of a Conda environment or the path to a
                        Conda environment yaml file. If provided, this describes the environment
                        this model should be run in. At minimum, it should specify the dependencies
                        contained in :func:`get_default_conda_env()`. If ``None``, the default
                        :func:`get_default_conda_env()` environment is added to the model.
                        The following is an *example* dictionary representation of a Conda
                        environment::
  
                          {
                              'name': 'mlflow-env',
                              'channels': ['defaults'],
                              'dependencies': [
                                  'python=3.7.0',
                                  'pip': [
                                      'ludwig==0.4.0'
                                  ]
                              ]
                          }
  
      :param mlflow_model: :py:mod:`mlflow.models.Model` this flavor is being added to.
  
      :param signature: (Experimental) :py:class:`ModelSignature <mlflow.models.ModelSignature>`
                        describes model input and output :py:class:`Schema <mlflow.types.Schema>`.
                        The model signature can be :py:func:`inferred <mlflow.models.infer_signature>`
                        from datasets with valid model input (e.g. the training dataset with target
                        column omitted) and valid model output (e.g. model predictions generated on
                        the training dataset), for example:
  
                        .. code-block:: python
  
                          from mlflow.models.signature import infer_signature
  
                          train = df.drop_column("target_label")
                          predictions = ...  # compute model predictions
                          signature = infer_signature(train, predictions)
      :param input_example: (Experimental) Input example provides one or several instances of valid
                            model input. The example can be used as a hint of what data to feed the
                            model. The given example will be converted to a Pandas DataFrame and then
                            serialized to json using the Pandas split-oriented format. Bytes are
                            base64-encoded.
      """
      import ludwig
  
      path = os.path.abspath(path)
      if os.path.exists(path):
          raise MlflowException(f"Path '{path}' already exists")
      model_data_subpath = "model"
      model_data_path = os.path.join(path, model_data_subpath)
      os.makedirs(path)
      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)
  
      # Save the Ludwig model
      ludwig_model.save(model_data_path)
  
      conda_env_subpath = "conda.yaml"
      if conda_env is None:
          conda_env = get_default_conda_env()
      elif not isinstance(conda_env, dict):
          with open(conda_env) as f:
              conda_env = yaml.safe_load(f)
      with open(os.path.join(path, conda_env_subpath), "w") as f:
          yaml.safe_dump(conda_env, stream=f, default_flow_style=False)
  
      pyfunc.add_to_model(
          mlflow_model,
          loader_module="ludwig.contribs.mlflow.model",
          data=model_data_subpath,
          env=conda_env_subpath,
      )
  
      schema_keys = {"name", "column", "type"}
      config = ludwig_model.config
  
      mlflow_model.add_flavor(
          FLAVOR_NAME,
          ludwig_version=ludwig.__version__,
          ludwig_schema={
              "input_features": [
                  {k: v for k, v in feature.items() if k in schema_keys}
                  for feature in config["input_features"]
              ],
              "output_features": [
                  {k: v for k, v in feature.items() if k in schema_keys}
                  for feature in config["output_features"]
              ],
          },
          data=model_data_subpath,
      )
      mlflow_model.save(os.path.join(path, MLMODEL_FILE_NAME))
  
imports: import logging
  import os
  import shutil
  import mlflow
  import yaml
  from mlflow import pyfunc
  from mlflow.exceptions import MlflowException
  from mlflow.models import Model
  from mlflow.models.model import MLMODEL_FILE_NAME
  from mlflow.models.signature import ModelSignature
  from mlflow.models.utils import _save_example, ModelInputExample
  from mlflow.tracking._model_registry import DEFAULT_AWAIT_MAX_SLEEP_SECONDS
  from mlflow.tracking.artifact_utils import _download_artifact_from_uri
  from mlflow.utils.environment import _mlflow_conda_env
  from mlflow.utils.model_utils import _get_flavor_configuration
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.globals import MODEL_HYPERPARAMETERS_FILE_NAME
  from ludwig.utils.data_utils import load_json
label_desc: Use image node_id 2 for calling a global function with example usage: save_model(ludwig_model, path, conda_env, mlflow_model, signature, input_example) without return types