def save(self, save_path: str):
        """
        Save the model to an ``.mlmodel`` format. For an MIL program, the ``save_path`` is
        a package directory containing the ``mlmodel`` and weights.

        Parameters
        ----------
        save_path: Target file path / bundle directory for the model.

        Examples
        --------
        .. sourcecode:: python

            model.save("my_model_file.mlmodel")
            loaded_model = MLModel("my_model_file.mlmodel")

        """
        save_path = _os.path.expanduser(save_path)

        # Clean up existing file or directory.
        if _os.path.exists(save_path):
            if _os.path.isdir(save_path):
                _shutil.rmtree(save_path)
            else:
                _os.remove(save_path)

        if self.is_package:
            name, ext = _os.path.splitext(save_path)
            if not ext:
                save_path = "{}{}".format(save_path, _MLPACKAGE_EXTENSION)
            elif ext != _MLPACKAGE_EXTENSION:
                raise Exception(
                    "For an ML Program, extension must be {} (not {}). Please see https://coremltools.readme.io/docs/unified-conversion-api#target-conversion-formats to see the difference between neuralnetwork and mlprogram model types.".format(
                        _MLPACKAGE_EXTENSION, ext
                    )
                )
            _shutil.copytree(self.package_path, save_path)

            if self._mil_program is not None and all(
                [
                    _ScopeSource.EXIR_DEBUG_HANDLE in function._essential_scope_sources for function in self._mil_program.functions.values()
                ]
            ):
                debug_handle_to_ops_mapping = (
                    self._mil_program.construct_debug_handle_to_ops_mapping()
                )
                if len(debug_handle_to_ops_mapping) > 0:
                    debug_handle_to_ops_mapping_as_json = json.dumps(
                        {
                            "version" : self.user_defined_metadata[_METADATA_VERSION],
                            "mapping" : debug_handle_to_ops_mapping,
                        }
                    )
                    saved_debug_handle_to_ops_mapping_path = _os.path.join(
                        save_path, "executorch_debug_handle_mapping.json"
                    )
                    with open(saved_debug_handle_to_ops_mapping_path, "w") as f:
                        f.write(debug_handle_to_ops_mapping_as_json)

            saved_spec_path = _get_model_spec_path(save_path)
            _save_spec(self._spec, saved_spec_path)
        else:
            _save_spec(self._spec, save_path)

        Save the model to an ``.mlmodel`` format. For an MIL program, the ``save_path`` is
        a package directory containing the ``mlmodel`` and weights.

        Parameters
        ----------
        save_path: Target file path / bundle directory for the model.

        Examples
        --------
        .. sourcecode:: python

            model.save("my_model_file.mlmodel")
            loaded_model = MLModel("my_model_file.mlmodel")

        
coremltools/models/model.py