code: def _eager_initial_values():
      """Attempts to force all initializers to create eager tensors."""
      all_initializers = {
          cls: cls.__call__
          for cls in initializers.Initializer.__subclasses__()
      }
  
      def patched_call(self, shape, dtype):
          """Monkey-patched verison of `Initializer.__call__`."""
          cls = type(self)
          orig_call = all_initializers[cls]
          try:
              with tf.init_scope():
                  return orig_call(self, shape, dtype)
          except:  # pylint: disable=bare-except
              if not tf.executing_eagerly():
                  logging.exception(
                      "Failed to create initial value eagerly for %s shape=%s dtype=%s",
                      type(self).__name__,
                      shape,
                      dtype,
                  )
              return orig_call(self, shape, dtype)
  
      try:
          for cls in all_initializers:
              cls.__call__ = patched_call
          yield
  
      finally:
          # Restore
          for cls, orig_call in all_initializers.items():
              cls.__call__ = orig_call
  
file_path: sonnet/sonnet/src/distribute/replicator.py
imports: from typing import Callable, TypeVar
  from absl import logging
  import contextlib
  from sonnet.src import initializers
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: _eager_initial_values() and returns: orig_call, orig_call