code: def testMinimizeSparseResourceVariable(self):
      for dtype in [dtypes.half, dtypes.float32, dtypes.float64]:
          # train.GradientDescentOptimizer is V1 only API.
          with ops.Graph().as_default(), self.cached_session():
              var0 = resource_variable_ops.ResourceVariable(
                  [[1.0, 2.0]], dtype=dtype
              )
              var1 = resource_variable_ops.ResourceVariable(
                  [3.0], dtype=dtype
              )
              x = constant_op.constant([[4.0], [5.0]], dtype=dtype)
              pred = math_ops.matmul(
                  embedding_ops.embedding_lookup([var0], [0]), x
              )
              pred += var1
              loss = pred * pred
              sgd_op = gradient_descent.GradientDescentOptimizer(
                  1.0
              ).minimize(loss)
              # TODO(apassos) calling initialize_resources on all resources here
              # doesn't work because the sessions and graph are reused across unit
              # tests and this would mean trying to reinitialize variables. Figure out
              # a long-term solution for this.
              self.evaluate(variables.global_variables_initializer())
              # Fetch params to validate initial values
              self.assertAllCloseAccordingToType(
                  [[1.0, 2.0]], self.evaluate(var0)
              )
              self.assertAllCloseAccordingToType(
                  [3.0], self.evaluate(var1)
              )
              # Run 1 step of sgd
              sgd_op.run()
              # Validate updated params
              np_pred = 1.0 * 4.0 + 2.0 * 5.0 + 3.0
              np_grad = 2 * np_pred
              self.assertAllCloseAccordingToType(
                  [[1.0 - np_grad * 4.0, 2.0 - np_grad * 5.0]],
                  self.evaluate(var0),
              )
              self.assertAllCloseAccordingToType(
                  [3.0 - np_grad], self.evaluate(var1)
              )
  
imports: 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.ops import embedding_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import resources
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.training import gradient_descent
label_desc: Use image node_id 5 for calling the GradientDescentOptimizerTest obj's underlying member method code with example usage: obj.testMinimizeSparseResourceVariable() without return types