code: def future_in_eager_mode(func_or_method):
      """Decorator that allow a function/method to run in graph and in eager modes.
  
      When applied in graph mode it calls the function and return its outputs.
      When applied in eager mode it returns a lambda function that when called
      returns the outputs.
  
      ```python
      @eager_utils.future_in_eager_mode
      def loss_fn(x):
        v = tf.get_variable('v', initializer=tf.ones_initializer(), shape=())
        return v + x
  
      with context.graph_mode():
        loss_op = loss_fn(inputs)
        loss_value = sess.run(loss_op)
  
      with context.eager_mode():
        loss = loss_fn(inputs)
        # Now loss is a Future callable.
        loss_value = loss()
      ```
  
      Args:
        func_or_method: A function or method to decorate.
  
      Returns:
        Either the output ops of the function/method or a Future (lambda function).
      """
      if not callable(func_or_method):
          raise TypeError("func_or_method must be callable.")
  
      def decorator(*args, **kwargs):
          if tf.executing_eagerly():
              return Future(func_or_method, *args, **kwargs)
          else:
              return func_or_method(*args, **kwargs)
  
      return tf_decorator.make_decorator(func_or_method, decorator)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import functools
  import inspect
  from absl import logging
  import numpy
  import six
  import tensorflow
  from tf_agents.utils import common
  from tensorflow.python.util import tf_decorator
label_desc: Use image node_id 3 for calling a global function with example usage: future_in_eager_mode(func_or_method) and returns: tf_decorator, Future, func_or_method