code: def save_model(
      name: Tag | str,
      model: SklearnModel,
      *,
      signatures: ModelSignaturesType | None = None,
      labels: t.Dict[str, str] | None = None,
      custom_objects: t.Dict[str, t.Any] | None = None,
      external_modules: t.List[ModuleType] | None = None,
      metadata: t.Dict[str, t.Any] | None = None,
  ) -> bentoml.Model:
      """
      Save a model instance to BentoML modelstore.
  
      Args:
          name: Name for given model instance. This should pass Python identifier check.
          model: Instance of model to be saved.
          signatures: Methods to expose for running inference on the target model. Signatures are
                      used for creating Runner instances when serving model with bentoml.Service
          labels: user-defined labels for managing models, e.g. team=nlp, stage=dev
          custom_objects: user-defined additional python objects to be saved alongside the model,
                          e.g. a tokenizer instance, preprocessor function, model configuration json
          external_modules: user-defined additional python modules to be saved alongside the model or custom objects,
                            e.g. a tokenizer module, preprocessor module, model configuration module
          metadata: Custom metadata for given model.
  
      Returns:
          :obj:`~bentoml.Tag`: A :obj:`tag` with a format ``name:version`` where ``name`` is
          the user-defined model's name, and a generated ``version``.
  
      Examples:
  
      .. code-block:: python
  
          import bentoml
  
          from sklearn.datasets import load_iris
          from sklearn.neighbors import KNeighborsClassifier
  
          model = KNeighborsClassifier()
          iris = load_iris()
          X = iris.data[:, :4]
          Y = iris.target
          model.fit(X, Y)
  
          bento_model = bentoml.sklearn.save_model('kneighbors', model)
      """  # noqa
      if not (
          LazyType("sklearn.base.BaseEstimator").isinstance(model)
          or LazyType("sklearn.pipeline.Pipeline").isinstance(model)
      ):
          raise TypeError(
              f"Given model ({model}) is not a sklearn.base.BaseEstimator or sklearn.pipeline.Pipeline."
          )
  
      context = ModelContext(
          framework_name="sklearn",
          framework_versions={
              "scikit-learn": get_pkg_version("scikit-learn")
          },
      )
  
      if signatures is None:
          signatures = {"predict": {"batchable": False}}
          logger.info(
              'Using the default model signature for scikit-learn (%s) for model "%s".',
              signatures,
              name,
          )
  
      with bentoml.models.create(
          name,
          module=MODULE_NAME,
          api_version=API_VERSION,
          labels=labels,
          custom_objects=custom_objects,
          external_modules=external_modules,
          metadata=metadata,
          context=context,
          signatures=signatures,
      ) as bento_model:
          joblib.dump(model, bento_model.path_of(MODEL_FILENAME))
  
          return bento_model
  
file_path: BentoML/grpc-client/bentoml/_internal/frameworks/sklearn.py
imports: from __future__ import annotations
  import logging
  import typing
  from types import ModuleType
  from typing import TYPE_CHECKING
  import bentoml
  from bentoml import Tag
  from bentoml.exceptions import MissingDependencyException
  from bentoml.exceptions import NotFound
  from bentoml.models import Model
  from bentoml.models import ModelContext
  from ..types import LazyType
  from ..utils.pkg import get_pkg_version
label_desc: Use image node_id 3 for calling a global function with example usage: save_model(name, model) and returns: bento_model