code: def testEmbeddingLookupGradientsHaveKnownShape(self):
      x = resource_variable_ops.ResourceVariable(
          initial_value=np.zeros([3, 3]),
          trainable=True,
          shape=[3, 3],
          dtype=dtypes.float32,
      )
  
      @def_function.function(input_signature=[])
      def _init():
          return x.assign(np.zeros([3, 3]))
  
      @def_function.function(input_signature=[])
      def _call():
          with gradients.GradientTape() as tape:
              y = embedding_ops.embedding_lookup_v2(x, [0])
              loss = math_ops.reduce_sum(y)
          grads = tape.gradient(loss, x)
          self.assertAllEqual(grads.shape, [3, 3])
          return ops.convert_to_tensor(grads)
  
      self.assertAllClose(self.evaluate(_init()), np.zeros([3, 3]))
  
      concrete_call = _call.get_concrete_function()
      self.assertAllClose(
          self.evaluate(concrete_call()),
          [[1.0, 1.0, 1.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
      )
  
file_path: tensorflow/tensorflow/python/ops/embedding_ops_test.py
imports: import numpy
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import embedding_ops
  from tensorflow.python.ops import gradients
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 2 for calling the EmbeddingLookupTest obj's underlying member method code with example usage: obj.testEmbeddingLookupGradientsHaveKnownShape() and returns: x, ops