code: def save_model(
      name: Tag | str,
      model: tf_ext.KerasModel | tf_ext.Module,
      *,
      tf_signatures: tf_ext.ConcreteFunction | None = None,
      tf_save_options: tf_ext.SaveOptions | None = None,
      signatures: dict[str, ModelSignature]
      | dict[str, ModelSignatureDict]
      | None = None,
      labels: dict[str, str] | None = None,
      custom_objects: dict[str, t.Any] | None = None,
      external_modules: list[ModuleType] | None = None,
      metadata: 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
          tf_signatures: Refer to `Signatures explanation <https://www.tensorflow.org/api_docs/python/tf/saved_model/save>`_
                         from Tensorflow documentation for more information.
          tf_save_options: TensorFlow save options..
          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.
  
      Raises:
          ValueError: If :obj:`obj` is not trackable.
  
      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`` by BentoML.
  
      Examples:
  
      .. code-block:: python
  
          import tensorflow as tf
          import numpy as np
          import bentoml
  
          class NativeModel(tf.Module):
              def __init__(self):
                  super().__init__()
                  self.weights = np.asfarray([[1.0], [1.0], [1.0], [1.0], [1.0]])
                  self.dense = lambda inputs: tf.matmul(inputs, self.weights)
  
              @tf.function(
                  input_signature=[tf.TensorSpec(shape=[1, 5], dtype=tf.float64, name="inputs")]
              )
              def __call__(self, inputs):
                  return self.dense(inputs)
  
          # then save the given model to BentoML modelstore:
          model = NativeModel()
          bento_model = bentoml.tensorflow.save_model("native_toy", model)
  
      .. note::
  
         :code:`bentoml.tensorflow.save_model` API also support saving `RaggedTensor <https://www.tensorflow.org/guide/ragged_tensor>`_ model and Keras model. If you choose to save a Keras model
         with :code:`bentoml.tensorflow.save_model`, then the model will be saved under a :obj:`SavedModel` format instead of :obj:`.h5`.
  
      """  # noqa
      context = ModelContext(
          framework_name="tensorflow",
          framework_versions={"tensorflow": get_tf_version()},
      )
  
      if signatures is None:
          restorable_functions = get_restorable_functions(model)
          if restorable_functions:
              signatures = {
                  k: {
                      "batchable": False,
                  }
                  for k in restorable_functions
              }
          else:
              signatures = {"__call__": {"batchable": False}}
          logger.info(
              'Using the default model signature for Tensorflow (%s) for model "%s".',
              signatures,
              name,
          )
  
      with bentoml.models.create(
          name,
          module=MODULE_NAME,
          api_version=API_VERSION,
          options=ModelOptions(),
          context=context,
          labels=labels,
          custom_objects=custom_objects,
          external_modules=external_modules,
          metadata=metadata,
          signatures=signatures,  # type: ignore
      ) as bento_model:
          tf.saved_model.save(
              model,
              bento_model.path,
              signatures=tf_signatures,
              options=tf_save_options,
          )
  
          return bento_model
  
imports: from __future__ import annotations
  import contextlib
  import itertools
  import logging
  import pickle
  import typing
  from types import ModuleType
  from typing import TYPE_CHECKING
  import bentoml
  from bentoml import Runnable
  from bentoml import Tag
  from bentoml.exceptions import MissingDependencyException
  from bentoml.exceptions import NotFound
  from bentoml.models import ModelContext
  from ..models.model import ModelSignature
  from ..models.model import PartialKwargsModelOptions
  from ..runner.container import DataContainer
  from ..runner.container import DataContainerRegistry
  from ..runner.container import Payload
  from ..types import LazyType
  from .utils.tensorflow import cast_py_args_to_tf_function_args
  from .utils.tensorflow import get_input_signatures_v2
  from .utils.tensorflow import get_output_signatures_v2
  from .utils.tensorflow import get_restorable_functions
  from .utils.tensorflow import get_tf_version
label_desc: Use image node_id 3 for calling a global function with example usage: save_model(name, model) and returns: bento_model