code: def export_bento(
      tag: Tag | str,
      path: str,
      output_format: str | None = None,
      *,
      protocol: str | None = None,
      user: str | None = None,
      passwd: str | None = None,
      params: dict[str, str] | None = None,
      subpath: str | None = None,
      _bento_store: BentoStore = Provide[BentoMLContainer.bento_store],
  ) -> str:
      """
      Export a bento.
  
      To export a bento to S3, you must install BentoML with extras ``aws``:
  
      .. code-block:: bash
  
         » pip install bentoml[aws]
  
      Examples:
  
      .. code-block:: python
  
          # exports 'my_bento' to '/path/to/folder/my_bento-version.bento' in BentoML's default format
          bentoml.export_bento('my_bento:latest', '/path/to/folder')
          # note that folders can only be passed if exporting to the local filesystem; otherwise the
          # full path, including the desired filename, must be passed
  
          # exports 'my_bento' to '/path/to/folder/my_bento.bento' in BentoML's default format
          bentoml.export_bento('my_bento:latest', '/path/to/folder/my_bento')
          bentoml.export_bento('my_bento:latest', '/path/to/folder/my_bento.bento')
  
          # exports 'my_bento' to '/path/to/folder/my_bento.tar.gz' in gzip format
          # currently supported formats are tar.gz ('gz'), tar.xz ('xz'), tar.bz2 ('bz2'), and zip
          bentoml.export_bento('my_bento:latest', '/path/to/folder/my_bento.tar.gz')
          # outputs a gzipped tarfile as 'my_bento.ext'
          bentoml.export_bento('my_bento:latest', '/path/to/folder/my_bento.ext', 'gz')
  
          # exports 'my_bento' to '/path/to/folder/my_bento/' as a folder
          bentoml.export_bento('my_bento:latest', '/path/to/folder/my_bento', 'folder')
  
          # exports 'my_bento' to the S3 bucket 'my_bucket' as 'folder/my_bento-version.bento'
          bentoml.export_bento('my_bento:latest', 's3://my_bucket/folder')
          bentoml.export_bento('my_bento:latest', 'my_bucket/folder', protocol='s3')
          bentoml.export_bento('my_bento:latest', 'my_bucket', protocol='s3', subpath='folder')
          bentoml.export_bento('my_bento:latest', 'my_bucket', protocol='s3', subpath='folder',
                               user='<AWS access key>', passwd='<AWS secret key>',
                               params={'acl': 'public-read', 'cache-control': 'max-age=2592000,public'})
  
      For a more comprehensive description of what each of the keyword arguments (:code:`protocol`,
      :code:`user`, :code:`passwd`, :code:`params`, and :code:`subpath`) mean, see the
      `FS URL documentation <https://docs.pyfilesystem.org/en/latest/openers.html>`_.
  
      Args:
          tag: the tag of the Bento to export
          path: can be either:
                * a folder on the local filesystem
                * an `FS URL <https://docs.pyfilesystem.org/en/latest/openers.html>`_. For example, :code:`'s3://my_bucket/folder/my_bento.bento'`
          protocol: (expert) The FS protocol to use when exporting. Some example protocols are :code:`'ftp'`, :code:`'s3'`, and :code:`'userdata'`
          user: (expert) the username used for authentication if required, e.g. for FTP
          passwd: (expert) the username used for authentication if required, e.g. for FTP
          params: (expert) a map of parameters to be passed to the FS used for export, e.g. :code:`{'proxy': 'myproxy.net'}` for setting a proxy for FTP
          subpath: (expert) the path inside the FS that the bento should be exported to
          _bento_store: save Bento created to this BentoStore
  
      Returns:
          str: A representation of the path that the Bento was exported to. If it was exported to the local filesystem,
              this will be the OS path to the exported Bento. Otherwise, it will be an FS URL.
      """
      bento = get(tag, _bento_store=_bento_store)
      return bento.export(
          path,
          output_format,
          protocol=protocol,
          user=user,
          passwd=passwd,
          params=params,
          subpath=subpath,
      )
  
imports: from __future__ import annotations
  import logging
  import os
  import re
  import subprocess
  import sys
  import tempfile
  import typing
  from simple_di import Provide
  from simple_di import inject
  from ._internal.bento import Bento
  from ._internal.bento.build_config import BentoBuildConfig
  from ._internal.configuration.containers import BentoMLContainer
  from ._internal.tag import Tag
  from ._internal.utils import resolve_user_filepath
  from .exceptions import BadInput
  from .exceptions import BentoMLException
  from .exceptions import InvalidArgument
label_desc: Use image node_id 5 for calling a global function with example usage: export_bento(tag, path, output_format) and returns: bento