def importing() -> t.Iterator[None]:
    """A context manager that suppresses the ImportError when importing runtime-specific modules.

    Example:

    .. code-block:: python

        with bentoml.importing():
            import torch
            import tensorflow
    """
    from bentoml._internal.context import server_context

    logger = logging.getLogger("bentoml.service")

    try:
        yield
    except ImportError as e:
        if server_context.worker_index is not None:
            raise
        logger.info(
            "Skipping import of module %s because it is not available in the current environment",
            e.name,
        )
A context manager that suppresses the ImportError when importing runtime-specific modules.

Example:

.. code-block:: python

with bentoml.importing():
import torch
import tensorflow
src/_bentoml_impl/loader.py