code: def test_tree_sum_noise_efficient(
      self, total_steps, noise_std, variable_shape, tolerance
  ):
      # Test the variance returned by `EfficientTreeAggregator` is smaller than
      # `TreeAggregator` (within a relative `tolerance`) after `total_steps` of
      # leaf nodes are traversed. Each tree node is a `variable_shape` tensor of
      # Gaussian noise with `noise_std`. A small `tolerance` is used for numerical
      # stability, `tolerance==0` means `EfficientTreeAggregator` is strictly
      # better than `TreeAggregator` for reducing variance.
      random_generator = tree_aggregation.GaussianNoiseGenerator(
          noise_std, tf.TensorSpec(variable_shape)
      )
      tree_aggregator = tree_aggregation.EfficientTreeAggregator(
          value_generator=random_generator
      )
      tree_aggregator_baseline = tree_aggregation.TreeAggregator(
          value_generator=random_generator
      )
  
      state = tree_aggregator.init_state()
      state_baseline = tree_aggregator_baseline.init_state()
      for leaf_node_idx in range(total_steps):
          self.assertEqual(
              leaf_node_idx, tree_aggregation.get_step_idx(state)
          )
          val, state = tree_aggregator.get_cumsum_and_update(state)
          (
              val_baseline,
              state_baseline,
          ) = tree_aggregator_baseline.get_cumsum_and_update(
              state_baseline
          )
      self.assertLess(
          tf.math.reduce_variance(val),
          (1 + tolerance) * tf.math.reduce_variance(val_baseline),
      )
  
imports: import math
  import random
  from absl.testing import parameterized
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import tree_aggregation
label_desc: Use image node_id 3 for calling the EfficientTreeAggregatorTest obj's underlying member method code with example usage: obj.test_tree_sum_noise_efficient(total_steps, noise_std, variable_shape, tolerance) without return types