@inject
def load(bento_tag: t.Union[(str, Tag)], tags: t.Optional[t.List[str]]=None, options: t.Optional['tf_ext.SaveOptions']=None, load_as_hub_module: t.Optional[bool]=None, model_store: 'ModelStore'=Provide[BentoMLContainer.model_store]) -> t.Union[('tf_ext.AutoTrackable', 'tf_ext.Module', 'HubModule', 'KerasLayer')]:
    '\n    Load a model from BentoML local modelstore with given name.\n\n    Args:\n        bento_tag (:code:`Union[str, Tag]`):\n            Tag of a saved model in BentoML local modelstore.\n        tags (:code:`str`, `optional`, defaults to `None`):\n            A set of strings specifying the graph variant to use, if loading from a v1 module.\n        options (:code:`tensorflow.saved_model.SaveOptions`, `optional`, default to :code:`None`):\n            :code:`tensorflow.saved_model.LoadOptions` object that specifies options for loading. This\n            argument can only be used from TensorFlow 2.3 onwards.\n        load_as_hub_module (`bool`, `optional`, default to :code:`True`):\n            Load the given weight that is saved from tfhub as either `hub.KerasLayer` or `hub.Module`.\n            The latter only applies for TF1.\n        model_store (:mod:`~bentoml._internal.models.store.ModelStore`, default to :mod:`BentoMLContainer.model_store`):\n            BentoML modelstore, provided by DI Container.\n\n    Returns:\n        :obj:`SavedModel`: an instance of :obj:`SavedModel` format from BentoML modelstore.\n\n    Examples:\n\n    .. code-block:: python\n\n        import bentoml\n\n        # load a model back into memory\n        model = bentoml.tensorflow.load("my_tensorflow_model")\n\n    '
    model = model_store.get(bento_tag)
    if (model.info.module not in (MODULE_NAME, __name__)):
        raise BentoMLException(f'Model {bento_tag} was saved with module {model.info.module}, failed loading with {MODULE_NAME}.')
    if model.info.context['import_from_tfhub']:
        assert (load_as_hub_module is not None), 'You have to specified `load_as_hub_module=True | False` to load a `tensorflow_hub` module. If True is chosen, then BentoML will return either an instance of `hub.KerasLayer` or `hub.Module` depending on your TF version. For most usecase, we recommend to keep `load_as_hub_module=True`. If you wish to extend the functionalities of the given model, set `load_as_hub_module=False` will return a SavedModel object.'
        if (hub is None):
            raise MissingDependencyException('            `tensorflow_hub` does not exists.\n            Make sure to `pip install --upgrade tensorflow_hub` before using.\n            ')
        module_path = model.path_of(model.info.options['local_path'])
        if load_as_hub_module:
            return (hub.Module(module_path) if get_tf_version().startswith('1') else hub.KerasLayer(module_path))
        is_hub_module_v1: bool = tf.io.gfile.exists(native_module.get_module_proto_path(module_path))
        if ((tags is None) and is_hub_module_v1):
            tags = []
        if (options is not None):
            if (not LazyType('tensorflow.python.saved_model.save_options.SaveOptions').isinstance(options)):
                raise BentoMLException(f'`options` has to be of type `tf.saved_model.SaveOptions`, got {type(options)} instead.')
            if (not hasattr(getattr(tf, 'saved_model', None), 'LoadOptions')):
                raise NotImplementedError(f'options are not supported for TF < 2.3.x, Current version: {get_tf_version()}')
            tf_model: 'tf_ext.AutoTrackable' = tf.compat.v1.saved_model.load_v2(module_path, tags=tags, options=options)
        else:
            tf_model: 'tf_ext.AutoTrackable' = tf.compat.v1.saved_model.load_v2(module_path, tags=tags)
        tf_model._is_hub_module_v1 = is_hub_module_v1
        return tf_model
    else:
        tf_model: 'tf_ext.AutoTrackable' = tf.compat.v1.saved_model.load_v2(model.path)
        return hook_loaded_model(tf_model, MODULE_NAME)
Load a model from BentoML local modelstore with given name.

Args:
    bento_tag (:code:`Union[str, Tag]`):
        Tag of a saved model in BentoML local modelstore.
    tags (:code:`str`, `optional`, defaults to `None`):
        A set of strings specifying the graph variant to use, if loading from a v1 module.
    options (:code:`tensorflow.saved_model.SaveOptions`, `optional`, default to :code:`None`):
        :code:`tensorflow.saved_model.LoadOptions` object that specifies options for loading. This
        argument can only be used from TensorFlow 2.3 onwards.
    load_as_hub_module (`bool`, `optional`, default to :code:`True`):
        Load the given weight that is saved from tfhub as either `hub.KerasLayer` or `hub.Module`.
        The latter only applies for TF1.
    model_store (:mod:`~bentoml._internal.models.store.ModelStore`, default to :mod:`BentoMLContainer.model_store`):
        BentoML modelstore, provided by DI Container.

Returns:
    :obj:`SavedModel`: an instance of :obj:`SavedModel` format from BentoML modelstore.

Examples:

.. code-block:: python

    import bentoml

    # load a model back into memory
    model = bentoml.tensorflow.load("my_tensorflow_model")
@inject
def load(bento_tag: t.Union[(str, Tag)], tags: t.Optional[t.List[str]]=None, options: t.Optional['tf_ext.SaveOptions']=None, load_as_hub_module: t.Optional[bool]=None, model_store: 'ModelStore'=Provide[BentoMLContainer.model_store]) -> t.Union[('tf_ext.AutoTrackable', 'tf_ext.Module', 'HubModule', 'KerasLayer')]:
    '\n    Load a model from BentoML local modelstore with given name.\n\n    Args:\n        bento_tag (:code:`Union[str, Tag]`):\n            Tag of a saved model in BentoML local modelstore.\n        tags (:code:`str`, `optional`, defaults to `None`):\n            A set of strings specifying the graph variant to use, if loading from a v1 module.\n        options (:code:`tensorflow.saved_model.SaveOptions`, `optional`, default to :code:`None`):\n            :code:`tensorflow.saved_model.LoadOptions` object that specifies options for loading. This\n            argument can only be used from TensorFlow 2.3 onwards.\n        load_as_hub_module (`bool`, `optional`, default to :code:`True`):\n            Load the given weight that is saved from tfhub as either `hub.KerasLayer` or `hub.Module`.\n            The latter only applies for TF1.\n        model_store (:mod:`~bentoml._internal.models.store.ModelStore`, default to :mod:`BentoMLContainer.model_store`):\n            BentoML modelstore, provided by DI Container.\n\n    Returns:\n        :obj:`SavedModel`: an instance of :obj:`SavedModel` format from BentoML modelstore.\n\n    Examples:\n\n    .. code-block:: python\n\n        import bentoml\n\n        # load a model back into memory\n        model = bentoml.tensorflow.load("my_tensorflow_model")\n\n    '
    model = model_store.get(bento_tag)
    if (model.info.module not in (MODULE_NAME, __name__)):
        raise BentoMLException(f'Model {bento_tag} was saved with module {model.info.module}, failed loading with {MODULE_NAME}.')
    if model.info.context['import_from_tfhub']:
        assert (load_as_hub_module is not None), 'You have to specified `load_as_hub_module=True | False` to load a `tensorflow_hub` module. If True is chosen, then BentoML will return either an instance of `hub.KerasLayer` or `hub.Module` depending on your TF version. For most usecase, we recommend to keep `load_as_hub_module=True`. If you wish to extend the functionalities of the given model, set `load_as_hub_module=False` will return a SavedModel object.'
        if (hub is None):
            raise MissingDependencyException('            `tensorflow_hub` does not exists.\n            Make sure to `pip install --upgrade tensorflow_hub` before using.\n            ')
        module_path = model.path_of(model.info.options['local_path'])
        if load_as_hub_module:
            return (hub.Module(module_path) if get_tf_version().startswith('1') else hub.KerasLayer(module_path))
        is_hub_module_v1: bool = tf.io.gfile.exists(native_module.get_module_proto_path(module_path))
        if ((tags is None) and is_hub_module_v1):
            tags = []
        if (options is not None):
            if (not LazyType('tensorflow.python.saved_model.save_options.SaveOptions').isinstance(options)):
                raise BentoMLException(f'`options` has to be of type `tf.saved_model.SaveOptions`, got {type(options)} instead.')
            if (not hasattr(getattr(tf, 'saved_model', None), 'LoadOptions')):
                raise NotImplementedError(f'options are not supported for TF < 2.3.x, Current version: {get_tf_version()}')
            tf_model: 'tf_ext.AutoTrackable' = tf.compat.v1.saved_model.load_v2(module_path, tags=tags, options=options)
        else:
            tf_model: 'tf_ext.AutoTrackable' = tf.compat.v1.saved_model.load_v2(module_path, tags=tags)
        tf_model._is_hub_module_v1 = is_hub_module_v1
        return tf_model
    else:
        tf_model: 'tf_ext.AutoTrackable' = tf.compat.v1.saved_model.load_v2(model.path)
        return hook_loaded_model(tf_model, MODULE_NAME)