code: def save_model(
      spark_model,
      sample_input,
      path,
      mlflow_model=None,
      signature: ModelSignature = None,
      input_example: ModelInputExample = None,
      metadata=None,
  ):
      """
      Save a Spark MLlib PipelineModel in MLeap format at a local path.
      The saved model will have the MLeap flavor.
  
      NOTE:
  
          You cannot load the MLeap model flavor in Python; you must download it using the
          Java API method ``downloadArtifacts(String runId)`` and load the model
          using the method ``MLeapLoader.loadPipeline(String modelRootPath)``.
  
      :param spark_model: Spark PipelineModel to be saved. This model must be MLeap-compatible and
                    cannot contain any custom transformers.
      :param sample_input: Sample PySpark DataFrame input that the model can evaluate. This is
                           required by MLeap for data schema inference.
      :param path: Local path where the model is to be saved.
      :param mlflow_model: :py:mod:`mlflow.models.Model` to which this flavor is being added.
  
      :param signature: :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) and valid
                        model output (e.g. model predictions generated on the training dataset),
                        for example:
  
                        .. code-block:: python
  
                          from mlflow.models import infer_signature
  
                          train = df.drop_column("target_label")
                          signature = infer_signature(train, model.predict(train))
      :param input_example: {{ input_example }}
  
      :param signature: :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 import infer_signature
  
                          train = df.drop_column("target_label")
                          predictions = ...  # compute model predictions
                          signature = infer_signature(train, predictions)
      :param input_example: {{ input_example }}
      :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.
      """
      if mlflow_model is None:
          mlflow_model = Model()
  
      add_to_model(
          mlflow_model=mlflow_model,
          path=path,
          spark_model=spark_model,
          sample_input=sample_input,
      )
      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
      mlflow_model.save(os.path.join(path, MLMODEL_FILE_NAME))
  
file_path: mlflow/mlflow/mleap/__init__.py
imports: import logging
  import os
  import pathlib
  import sys
  import traceback
  import mlflow
  from mlflow.exceptions import MlflowException
  from mlflow.models import Model, ModelInputExample, ModelSignature
  from mlflow.models.model import MLMODEL_FILE_NAME
  from mlflow.models.utils import _save_example
  from mlflow.utils import reraise
  from mlflow.utils.annotations import deprecated, keyword_only
  from mlflow.utils.file_utils import path_to_local_file_uri
label_desc: Use image node_id 2 for calling a global function with example usage: save_model(spark_model, sample_input, path, mlflow_model, signature, input_example, metadata) without return types