code: def lazy_imports(
      error_callback: Optional[Callback] = None,
      success_callback: Optional[Callback] = None,
  ) -> Iterator[None]:
      """Context Manager which lazy loads packages.
  
      Their import is not executed immediately, but is postponed to the first
      call of one of their attributes.
  
      Warning: mind current implementation's limitations:
  
      - You can only lazy load modules (`from x import y` will not work if `y` is a
        constant or a function or a class).
      - You cannot `import x.y` if `y` is not imported in the `x/__init__.py`.
  
      Usage:
  
      ```python
      from tensorflow_datasets.core.utils.lazy_imports_utils import lazy_imports
  
      with lazy_imports():
        import tensorflow as tf
      ```
  
      Args:
        error_callback: a callback to trigger when an import fails. The callback is
          passed kwargs containing: 1) exception (ImportError): the exception that
          was raised after the error; 2) module_name (str): the name of the imported
          module.
        success_callback: a callback to trigger when an import succeeds. The
          callback is passed kwargs containing: 1) `import_time_ms` (float) for the
          import time (in milliseconds); 2) `module` (Any) for the imported module;
          3) `module_name` (str) for the name of the imported module.
  
      Yields:
        None
      """
      # Need to mock `__import__` (instead of `sys.meta_path`, as we do not want
      # to modify the `sys.modules` cache in any way)
      original_import = builtins.__import__
      try:
          builtins.__import__ = functools.partial(
              _lazy_import,
              error_callback=error_callback,
              success_callback=success_callback,
          )
          yield
      finally:
          builtins.__import__ = original_import
  
file_path: datasets/tensorflow_datasets/core/utils/lazy_imports_utils.py
imports: from __future__ import annotations
  import builtins
  import contextlib
  import dataclasses
  import functools
  import importlib
  import time
  import types
  from typing import Any, Callable, Iterator, Optional, Tuple
label_desc: Use image node_id 1 for calling a global function with example usage: lazy_imports(error_callback, success_callback) without return types