class_docstr: Tests for _compute_gradients method.
class_docstr_tok: ["Tests","for","_compute_gradients","method","."]
code: def testClippingNorm(self, optimizer_class, requires_varlist):
      var0 = tf.Variable([0.0, 0.0])
      data0 = tf.Variable([[3.0, 4.0], [6.0, 8.0]])
  
      varlist_kwarg = (
          {"var_list_or_model": [var0]} if requires_varlist else {}
      )
  
      optimizer = optimizer_class(
          l2_norm_clip=1.0,
          noise_multiplier=0.0,
          num_microbatches=1,
          **varlist_kwarg,
          learning_rate=2.0,
      )
  
      loss = lambda: self._loss(data0, var0)
      # Expected gradient is sum of differences.
      grads_and_vars = optimizer._compute_gradients(loss, [var0])
      self.assertAllCloseAccordingToType(
          [-0.6, -0.8], grads_and_vars[0][0]
      )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_keras
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_keras_vectorized
label_desc: Use image node_id 7 for calling the DPOptimizerComputeGradientsTest obj's underlying member method code with example usage: obj.testClippingNorm(optimizer_class, requires_varlist) without return types