code: def dense_gradient(x: tf.Tensor):
      """Identity operation whose gradient is converted to a ``tf.Tensor``.
  
      >>> embedding = tf.Variable(tf.random.normal([3, 3]))
      >>> with tf.GradientTape() as tape:
      ...   y = tf.nn.embedding_lookup(dense_gradient(embedding), [1])
      >>> tape.gradient(y, embedding).numpy()
      array([[ 0.,  0.,  0.],
             [ 1.,  1.,  1.],
             [ 0.,  0.,  0.]], dtype=float32)
  
      Args:
        x: A ``tf.Tensor``.
  
      Returns:
        The input ``tf.Tensor`` and a dense identity gradient function.
      """
  
      def grad(dy):
          if isinstance(dy, tf.IndexedSlices):
              return tf.convert_to_tensor(dy)
          else:
              return dy
  
      return x, grad
  
file_path: sonnet/sonnet/src/embed.py
imports: import math
  from typing import Optional
  from sonnet.src import base
  from sonnet.src import initializers
  from sonnet.src import types
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: dense_gradient(x) and returns: x,  grad, tf, dy