code: def testPrecomputedGradient(self):
      for dtype in [dtypes.half, dtypes.float32, dtypes.float64]:
          with self.cached_session():
              var0 = variables.Variable([1.0, 2.0], dtype=dtype)
              var1 = variables.Variable([3.0, 4.0], dtype=dtype)
              cost = 5 * var0 + 3 * var1
              grad_loss = constant_op.constant([42, -42], dtype=dtype)
              global_step = variables.Variable(
                  array_ops.zeros([], dtypes.int64), name="global_step"
              )
              sgd_op = gradient_descent.GradientDescentOptimizer(3.0)
              opt_op = sgd_op.minimize(
                  cost, global_step, [var0, var1], grad_loss=grad_loss
              )
  
              self.evaluate(variables.global_variables_initializer())
              # Fetch params to validate initial values
              self.assertAllClose([1.0, 2.0], self.evaluate(var0))
              self.assertAllClose([3.0, 4.0], self.evaluate(var1))
              # Run 1 step of sgd through optimizer
              opt_op.run()
              # Validate updated params
              self.assertAllClose(
                  [1.0 - 3 * 5 * 42.0, 2.0 - 3 * 5 * (-42.0)],
                  self.evaluate(var0),
              )
              self.assertAllClose(
                  [3.0 - 3 * 3 * 42.0, 4.0 - 3 * 3 * (-42.0)],
                  self.evaluate(var1),
              )
  
imports: from tensorflow.python.distribute import cross_device_ops
  from tensorflow.python.distribute import distribute_utils
  from tensorflow.python.distribute import mirrored_strategy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import clip_ops
  from tensorflow.python.ops import gradients_util
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import state_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.training import adam
  from tensorflow.python.training import gradient_descent
label_desc: Use image node_id 3 for calling the OptimizerTest obj's underlying member method code with example usage: obj.testPrecomputedGradient() without return types