class_docstr: Tests for _compute_gradients method.
class_docstr_tok: ["Tests","for","_compute_gradients","method","."]
docstr: Tests that assertion fails when DP gradients are not computed.
code: def testRaisesOnNoCallOfComputeGradients(self):
      """Tests that assertion fails when DP gradients are not computed."""
      variables = [tf.Variable([0.0])]
      optimizer = dp_optimizer_keras.DPFTRLTreeAggregationOptimizer(
          l2_norm_clip=100.0,
          noise_multiplier=0.0,
          num_microbatches=1,
          learning_rate=2.0,
          restart_period=None,
          restart_warmup=None,
          var_list_or_model=variables,
      )
  
      with self.assertRaises(AssertionError):
          optimizer.apply_gradients(variables)
  
      # Expect no exception if _compute_gradients is called.
      data0 = tf.Variable([[0.0]])
      loss = lambda: self._loss(data0, variables[0])
      grads_and_vars = optimizer._compute_gradients(loss, variables[0])
      optimizer.apply_gradients(grads_and_vars)
  
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 4 for calling the DPTreeAggregationOptimizerComputeGradientsTest obj's underlying member method code with example usage: obj.testRaisesOnNoCallOfComputeGradients() without return types