code: def as_numpy(function: _Decorator) -> _Decorator:
      """Decorator to call `as_numpy` method on registered loggers."""
  
      # Here we use `functools.wraps` as `wrapt.decorator` is not serializable.
      # https://github.com/GrahamDumpleton/wrapt/issues/158.
      @functools.wraps(function)
      def decorator(*args, **kwargs):
          dataset = args[0] if args else kwargs["dataset"]
          metadata = call_metadata.CallMetadata()
          try:
              return function(*args, **kwargs)
          except Exception:
              metadata.mark_error()
              raise
          finally:
              metadata.mark_end()
              for logger in _get_registered_loggers():
                  logger.as_numpy(metadata=metadata, dataset=dataset)
  
      return decorator
  
imports: import abc
  import atexit
  import collections
  import functools
  import threading
  from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar
  from absl import flags
  from tensorflow_datasets.core.logging import base_logger
  from tensorflow_datasets.core.logging import call_metadata
  from tensorflow_datasets.core.logging import logging_logger
  import wrapt
label_desc: Use image node_id 8 for calling a global function with example usage: as_numpy(function) and returns: decorator, function