class_docstr: Tests dp_optimizer_keras_sparse optimizers.
class_docstr_tok: ["Tests","dp_optimizer_keras_sparse","optimizers","."]
code: def testClippingNorm(self, cls):
      var0 = tf.Variable([0.0, 0.0])
      data0 = tf.Variable([[3.0, 4.0], [6.0, 8.0]])
  
      opt = cls(
          l2_norm_clip=1.0,
          noise_multiplier=0.0,
          num_microbatches=1,
          learning_rate=2.0,
      )
  
      loss = lambda: self._loss(data0, var0)
      # Expected gradient is sum of differences.
      grads_and_vars = opt._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_privacy.privacy.optimizers import dp_optimizer_keras_sparse
label_desc: Use image node_id 5 for calling the DPOptimizerTest obj's underlying member method code with example usage: obj.testClippingNorm(cls) without return types