code: def test_noisy_sum(self, stddev):
      num_trials = 1000
      record_1 = tf.zeros([num_trials], dtype=tf.int32)
      record_2 = tf.ones([num_trials], dtype=tf.int32)
      sample = [record_1, record_2]
      query = dg_sum_query(l2_norm_bound=num_trials, stddev=stddev)
      result, _ = test_utils.run_query(query, sample)
  
      sampled_noise = discrete_gaussian_utils.sample_discrete_gaussian(
          scale=tf.cast(stddev, tf.int32),
          shape=[num_trials],
          dtype=tf.int32,
      )
  
      result, sampled_noise = self.evaluate([result, sampled_noise])
  
      # The standard error of the stddev should be roughly sigma / sqrt(2N - 2),
      # (https://stats.stackexchange.com/questions/156518) so set a rtol to give
      # < 0.01% of failure (within ~4 standard errors).
      rtol = 4 / np.sqrt(2 * num_trials - 2)
      self.assertAllClose(np.std(result), stddev, rtol=rtol)
  
      # Use standard error of the mean to compare percentiles.
      stderr = stddev / np.sqrt(num_trials)
      self.assertAllClose(
          np.percentile(result, [25, 50, 75]),
          np.percentile(sampled_noise, [25, 50, 75]),
          atol=4 * stderr,
      )
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/discrete_gaussian_query_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import discrete_gaussian_query
  from tensorflow_privacy.privacy.dp_query import discrete_gaussian_utils
  from tensorflow_privacy.privacy.dp_query import test_utils
label_desc: Use image node_id 7 for calling the DiscreteGaussianQueryTest obj's underlying member method code with example usage: obj.test_noisy_sum(stddev) without return types