def _add_modelpath_to_cache(self, model_path: str) -> None:
        """
        Given an ``mlpackage`` path ``model_path``, this function caches related metadata.
        """
        if model_path in self._modelpath_to_functions:
            return

        try:
            spec = load_spec(model_path)
        except Exception as err:
            raise ValueError(f"invalid model_path {model_path} with error {err} while loading.")

        desc = spec.description

        # For the protobuf in iOS17 and below, there was no `functions` field,
        # so "main" is the only function associated with the model in those cases.
        if len(desc.functions) == 0:
            self._modelpath_to_functions[model_path] = ["main"]
        else:
            self._modelpath_to_functions[model_path] = [func.name for func in desc.functions]
        self._modelpath_to_spec[model_path] = spec

        Given an ``mlpackage`` path ``model_path``, this function caches related metadata.
        
coremltools/models/utils.py