class_docstr: Tests dp_optimizer_keras_sparse optimizers.
class_docstr_tok: ["Tests","dp_optimizer_keras_sparse","optimizers","."]
docstr: Tests that get_gradients raises an error.
docstr_tok: ["Tests","that","get_gradients","raises","an","error","."]
code: def testNoGetGradients(self, cls):
      """Tests that get_gradients raises an error."""
      var0 = tf.Variable([[1.0, 2.0]], dtype=tf.float32)
      x1 = tf.constant([[2.0, 0.0], [0.0, 1.0]], dtype=tf.float32)
      loss1 = lambda: tf.matmul(var0, x1, transpose_b=True)
      opt = cls(
          l2_norm_clip=100.0,
          noise_multiplier=0.0,
          num_microbatches=1,
          learning_rate=2.0,
      )
  
      with self.assertRaises(ValueError):
          opt.get_gradients(loss1, var0)
  
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 9 for calling the DPOptimizerTest obj's underlying member method code with example usage: obj.testNoGetGradients(cls) without return types