code: def _recomputing_grad_fn(
      compute_fn,
      original_args,
      original_vars,
      output_grads,
      grad_fn_variables,
      use_data_dep,
      tupleize_grads,
      arg_scope,
      var_scope,
      has_is_recompute_kwarg,
  ):
      """Grad fn for recompute_grad."""
      variables = grad_fn_variables or []
  
      # Identity ops around the inputs ensures correct gradient graph-walking.
      inputs = [array_ops.identity(x) for x in list(original_args)]
  
      # Recompute outputs
      # Use a control dependency to ensure that the recompute is not eliminated by
      # CSE and that it happens on the backwards pass.
      ctrl_dep_grads = [g for g in output_grads if g is not None]
      with framework_ops.control_dependencies(ctrl_dep_grads):
          if use_data_dep:
              inputs = _force_data_dependency(output_grads, inputs)
          # Re-enter scopes
          with contrib_framework_ops.arg_scope(arg_scope):
              with variable_scope.variable_scope(var_scope, reuse=True):
                  # Re-call the function and ensure that the touched variables are the
                  # same as in the first call.
                  with backprop.GradientTape() as tape:
                      fn_kwargs = {}
                      if has_is_recompute_kwarg:
                          fn_kwargs["is_recomputing"] = True
                      outputs = compute_fn(*inputs, **fn_kwargs)
                  recompute_vars = set(tape.watched_variables())
                  if original_vars != recompute_vars:
                      raise ValueError(_WRONG_VARS_ERR)
  
      if not isinstance(outputs, (list, tuple)):
          outputs = [outputs]
      outputs = list(outputs)
  
      # Compute gradients
      grads = gradients_impl.gradients(
          outputs, inputs + variables, output_grads
      )
  
      if tupleize_grads:
          if use_data_dep:
              grads = _tuple_with_data_dep(grads)
          else:
              grads = control_flow_ops.tuple(grads)
  
      grad_inputs = grads[: len(inputs)]
      grad_vars = grads[len(inputs) :]
      return grad_inputs, grad_vars
  
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 11 for calling a global function with example usage: _recomputing_grad_fn(compute_fn, original_args, original_vars, output_grads, grad_fn_variables, use_data_dep, tupleize_grads, arg_scope, var_scope, has_is_recompute_kwarg) and returns: grad_inputs,  grad_vars