code: def _resolve_grad_captures(body_graph, body_grad_graph, while_op):
      """Returns the tensors to pass as captured inputs to `body_grad_graph`.
  
      `body_grad_graph` may have external references to:
      1. Its outer graph containing the input gradients. These are left as-is.
      2. Accumulators captured from the forward-pass graph. These should have been
         added as `while_op` outputs after the gradient graph was built. We replace
         these with the corresponding output of `while_op`, i.e. a tensor in
         `body_graph.outer_graph`. In the case of nested control flow or functions,
         the gradient logic handling `body_grad_graph.outer_graph` will make sure
         the tensor from `body_graph.outer_graph` is also correctly captured.
  
      Args:
        body_graph: FuncGraph. The forward-pass body function.
        body_grad_graph: FuncGraph. The body gradients function.
        while_op: The forward-pass While Operation calling `body_graph`.
  
      Returns:
        A list of input tensors to be passed as the captured inputs to
        `body_grad_graph`.
      """
      new_capture_inputs = []
      for t in body_grad_graph.external_captures:
          # Resolve tensors captured from the forward graph to the outputs of the
          # forward while_op.
          if t.graph == body_graph:
              # Captured accumulator or loop invariant.
              for i, output in enumerate(t.graph.outputs):
                  if output is t:
                      t = while_op.outputs[i]
                      break
  
              # Note: We rely on the capturing logic of the gradient While op graph to
              # correctly capture the tensors in `body_graph.outer_graph`. Both cond_v2
              # and while_v2 handle this while building their gradient functions.
              assert t.graph == body_graph.outer_graph
  
          new_capture_inputs.append(t)
      return new_capture_inputs
  
imports: import collections
  from tensorflow.core.framework import attr_value_pb2
  from tensorflow.python.client import pywrap_tf_session
  from tensorflow.python.eager import backprop_util
  from tensorflow.python.framework import auto_control_deps_utils
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import func_graph
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import tensor_util
  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 control_flow_util_v2
  from tensorflow.python.ops import default_gradient
  from tensorflow.python.ops import gen_functional_ops
  from tensorflow.python.ops import gen_resource_variable_ops
  from tensorflow.python.ops import gradients_util
  from tensorflow.python.ops import handle_data_util
  from tensorflow.python.ops import list_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import tensor_array_ops
  from tensorflow.python.ops import while_v2_indexed_slices_rewriter
  from tensorflow.python.util import compat
  from tensorflow.python.util import nest
  from tensorflow.python.util import object_identity
  from tensorflow.python.util import variable_utils
label_desc: Use image node_id 11 for calling a global function with example usage: _resolve_grad_captures(body_graph, body_grad_graph, while_op) and returns: new_capture_inputs