code: def _compute_dx_and_dy(x, y, y_shape):
      """Returns a node to compute gradient of y wrt x."""
      # We make up a dy so that we can compute the gradients. We don't really use
      # the value of dy -- we will always feed it. We need to add an identity node
      # so that we can always feed it properly. Otherwise, for the Add operation,
      # dx is the same as dy and we cannot fetch the tensor that we are feeding.
      with x.graph.as_default():
          dy_orig = constant_op.constant(
              1.0, shape=y_shape, dtype=y.dtype
          )
          dy = array_ops.identity(dy_orig)
      # We compute the gradients for y wrt. x
      grads = gradients.gradients(y, x, dy)
      assert len(grads) == 1
      return grads[0], dy_orig
  
imports: import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradients
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 5 for calling a global function with example usage: _compute_dx_and_dy(x, y, y_shape) and returns: grads,  dy_orig