code: def recompute_grad(
      fn, use_data_dep=_USE_DEFAULT, tupleize_grads=False
  ):
      """Decorator that recomputes the function on the backwards pass.
  
      To use this function, you must use `ResourceVariable`s (i.e.
      `variable_scope(name, use_resource=True), which are the default in Eager mode
      and when running on TPU.
  
      Warning: Because the function will be called again on the backwards pass, the
      user should be careful to not use ops in their function that mutate state or
      have randomness (for example, batch normalization or dropout). If the function
      does have such operations, it is recommended that the function take the
      `is_recomputing` keyword argument which will be `False` on the forward pass
      and `True` on the backwards pass so that it can disable state changes when
      `is_recomputing=True` (for example, not updating the moving averages in batch
      normalization).
  
      Args:
        fn: a function that takes Tensors (all as positional arguments) and returns
          a tuple of Tensors. Note that `fn` should not close over any other
          Tensors or Variables.
        use_data_dep: `bool`, if `True` will use a dummy data dependency to force
          the recompute to happen. If `False` will use a control dependency. By
          default will be `True` if in an XLA context and `False` otherwise. XLA
          ignores control dependencies and so this data dependency is necessary.
        tupleize_grads: `bool`, if `True` will use control dependencies to ensure
          that all gradients are produced before any are consumed by downstream ops.
          If `use_data_dep` is also `True`, will use a data dependency instead of
          a control dependency.
  
      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).
  
      Raises:
        ValueError: if `fn` closes over any Tensors or Variables.
      """
      # Check for closed-over Tensors/Variables
      if fn.__code__.co_freevars:
          closed_over_vars = dict(
              zip(
                  fn.__code__.co_freevars,
                  [c.cell_contents for c in fn.__closure__],
              )
          )
          for var_name, value in six.iteritems(closed_over_vars):
              if isinstance(
                  value, (framework_ops.Tensor, variables_lib.Variable)
              ):
                  raise ValueError(
                      "fn decorated with @recompute_grad closes over Tensor %s "
                      "(local variable name: %s). The decorated fn must not close over "
                      "Tensors or Variables because gradients will NOT be computed for "
                      "them through fn. To ensure correct gradients, make the "
                      "Tensor an input to fn." % (value.name, var_name)
                  )
  
      @_safe_wraps(fn)
      def wrapped(*args):
          return _recompute_grad(
              fn,
              args,
              use_data_dep=use_data_dep,
              tupleize_grads=tupleize_grads,
          )
  
      return wrapped
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import re
  import numpy
  import six
  from six.moves import xrange
  from ..None import contrib_framework
  from tensorflow.python.eager import backprop
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.layers import base
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.ops import custom_gradient
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import nest
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 9 for calling a global function with example usage: recompute_grad(fn, use_data_dep, tupleize_grads) and returns: wrapped, _recompute_grad