code: def _resolve_grad_inputs(cond_graph, grad_graph):
      """Returns the tensors to pass as inputs to `grad_graph`.
  
      The `grad_graph` may have external references to
      1. Its outer graph containing the input gradients. These references are kept
         as is.
      2. Tensors in the forward pass graph. These tensors may not be "live"
         when the gradient is being computed. We replace such references by their
         corresponding tensor in `cond_graph.outer_graph`. In the case of nested
         control flow or functions, the gradient logic handling
         `grad_graph.outer_graph` will make sure the tensor from
         `cond_graph.outer_graph` is also correctly captured.
  
      Args:
        cond_graph: FuncGraph. The forward-pass function.
        grad_graph: FuncGraph. The gradients function.
  
      Returns:
        A list of inputs tensors to be passed to grad_graph.
      """
      new_inputs = []
  
      for t in grad_graph.external_captures:
          # `t` must either be in `grad_graph.outer_graph` or in the forward
          # `cond_graph`.
          if t.graph != grad_graph.outer_graph:
              assert t.graph == cond_graph
              # `internal_captures` are not treated as intermediates and hence not added
              # to If op outputs. So we get the outer tensor corresponding to those
              # from the list of `external_captures`.
              for i, output in enumerate(t.graph.outputs):
                  if output is t:
                      t = t.graph._forward_cond.outputs[i]
                      break
              else:
                  for i, output in enumerate(t.graph.internal_captures):
                      if output is t:
                          t = t.graph.external_captures[i]
                          break
                  else:
                      raise ValueError(
                          "Could not find external tensor capture {tensor} in "
                          "captures or outputs".format(tensor=t)
                      )
  
              # Note: We rely on the capturing logic of the gradient If op graph to
              # correctly capture the tensors in `cond_graph.outer_graph`. Both cond_v2
              # and while_v2 handle this while building their gradient functions.
              assert t.graph == cond_graph.outer_graph
          new_inputs.append(t)
  
      return new_inputs
  
imports: import collections
  from tensorflow.core.framework import types_pb2
  from tensorflow.python.eager import backprop_util
  from tensorflow.python.framework import auto_control_deps
  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 errors_impl
  from tensorflow.python.framework import func_graph
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import none_tensor
  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_util
  from tensorflow.python.framework import type_spec
  from tensorflow.python.ops import array_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_optional_ops
  from tensorflow.python.ops import gradients_util
  from tensorflow.python.ops import handle_data_util
  from tensorflow.python.ops import math_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 11 for calling a global function with example usage: _resolve_grad_inputs(cond_graph, grad_graph) and returns: new_inputs