class_docstr: Tests clip_and_aggreate_gradients.
docstr: Tests the correctness of the computation for tensors.
docstr_tok: ["Tests","the","correctness","of","the","computation","for","tensors","."]
code: def testCorrectTensor(
      self,
      n,
      normalize,
      l2_norm_clip,
      agg_method,
      keep_sparse_threshold,
      unconnected,
  ):
      """Tests the correctness of the computation for tensors."""
      true_grads = self._get_true_grads(
          n, normalize, l2_norm_clip, agg_method, unconnected
      )
  
      tape = tf.GradientTape()
      with tape:
          loss, test_vars = self._get_loss_and_vars(n)
      results = cag.clip_and_aggregate_gradients(
          tape,
          loss,
          test_vars,
          normalize=normalize,
          l2_norm_clip=l2_norm_clip,
          aggregate_method=agg_method,
          unconnected_gradients=unconnected,
          keep_sparse_threshold=keep_sparse_threshold,
      )
      for r, t in zip(results, true_grads):
          if t is None:
              self.assertIsNone(r)
          else:
              r = self._to_dense_array(r)
              self.assertAllCloseAccordingToType(r, t)
  
file_path: privacy/tensorflow_privacy/privacy/optimizers/clip_and_aggregate_gradients_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_privacy.privacy.optimizers import clip_and_aggregate_gradients
label_desc: Use image node_id 4 for calling the ClipAndAggregateGradientsTest obj's underlying member method code with example usage: obj.testCorrectTensor(n, normalize, l2_norm_clip, agg_method, keep_sparse_threshold, unconnected) without return types