code: def decorator(
      decorator_fn: Callable[
          [T, Any, Sequence[Any], Dict[str, Any]], Any
      ],
  ) -> T:
      """Returns a wrapt style decorator."""
  
      @functools.wraps(decorator_fn)
      def _decorator(f):
          """Wraps f such that it returns the result of applying decorator_fn."""
          if _is_object(f):
  
              @functools.wraps(f.__call__)
              def _decorate_object(*args, **kwargs):
                  return decorator_fn(f.__call__, f, args, kwargs)
  
              return _decorate_object
  
          if inspect.ismethod(f):
  
              @functools.wraps(f)
              def _decorate_bound_method(*args, **kwargs):
                  return decorator_fn(f, f.__self__, args, kwargs)
  
              return _decorate_bound_method
  
          argspec = inspect.getfullargspec(f)
          if argspec.args and argspec.args[0] == "self":
              # TODO(b/123870292): Bound methods with multiple decorators can be
              # detected as unbound too, which breaks tf.function usage.
              # Attempt migrating to wrapt instead of using this custom approach.
              def _decorate_unbound_method(self, *args, **kwargs):
                  bound_method = f.__get__(
                      self, self.__class__
                  )  # pytype: disable=attribute-error
                  return decorator_fn(bound_method, self, args, kwargs)
  
              return _decorate_unbound_method
  
          @functools.wraps(f)
          def _decorate_fn(*args, **kwargs):
              return decorator_fn(f, None, args, kwargs)
  
          return _decorate_fn
  
      return _decorator
  
imports: import collections.abc
  import functools
  import inspect
  import re
  import threading
  from typing import Any, Callable, Dict, Generic, Optional, Sequence, Tuple, TypeVar, Union
  from absl import logging
  from sonnet.src import initializers
  import tabulate
  import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: decorator(decorator_fn) and returns: _decorator, _decorate_fn, _decorate_object, _decorate_bound_method, _decorate_unbound_method, decorator_fn, decorator_fn, decorator_fn, decorator_fn