code: def recompute_grad(fn, use_entire_scope=False, train_vars=None):
      """Decorator that recomputes the function on the backwards pass.
      Args:
        fn: a function that takes Tensors (all as positional arguments) and returns
          a tuple of Tensors.
      Returns:
        A wrapped fn that is identical to fn when called, but its activations will
        be discarded and recomputed on the backwards pass (i.e. on a call to
        tf.gradients).
        :param use_entire_scope:
      """
  
      @functools.wraps(fn)
      def wrapped(*args):
          out = _recompute_grad(
              fn,
              args,
              use_entire_scope=use_entire_scope,
              train_vars=train_vars,
          )
          if isinstance(out, tuple) and len(out) == 1:
              return out[0]
          return out
  
      return wrapped
  
file_path: finetune/finetune/optimizers/recompute_grads.py
imports: import functools
  import tensorflow
  from tensorflow.python.framework import function, ops
  from finetune.util.optimize_loss import is_numerical_tensor
label_desc: Use image node_id 3 for calling a global function with example usage: recompute_grad(fn, use_entire_scope, train_vars) and returns: wrapped, out, out