class_docstr: Implements DPQuery for discrete distributed Gaussian sum queries.
  
  For each local record, we check the L2 norm bound and add discrete Gaussian
  noise. In particular, this DPQuery does not perform L2 norm clipping and the
  norms of the input records are expected to be bounded.
class_docstr_tok: ["Implements","DPQuery","for","discrete","distributed","Gaussian","sum","queries",".","For","each","local","record",",","we","check","the","L2","norm","bound","and","add","discrete","Gaussian","noise",".","In","particular",",","this","DPQuery","does","not","perform","L2","norm","clipping","and","the","norms","of","the","input","records","are","expected","to","be","bounded","."]
docstr: Add local discrete Gaussian noise to the record.
  
  Args:
    record: The record to which we generate and add local noise.
    local_stddev: The stddev of the local discrete Gaussian noise.
    shares: Number of shares of local noise to generate. Should be 1 for each
      record. This can be useful when we want to generate multiple noise
      shares at once.
  
  Returns:
    The record with local noise added.
docstr_tok: ["Add","local","discrete","Gaussian","noise","to","the","record",".","Args",":","record",":","The","record","to","which","we","generate","and","add","local","noise",".","local_stddev",":","The","stddev","of","the","local","discrete","Gaussian","noise",".","shares",":","Number","of","shares","of","local","noise","to","generate",".","Should","be","1","for","each","record",".","This","can","be","useful","when","we","want","to","generate","multiple","noise","shares","at","once",".","Returns",":","The","record","with","local","noise","added","."]
code: def _add_local_noise(self, record, local_stddev, shares=1):
      """Add local discrete Gaussian noise to the record.
  
      Args:
        record: The record to which we generate and add local noise.
        local_stddev: The stddev of the local discrete Gaussian noise.
        shares: Number of shares of local noise to generate. Should be 1 for each
          record. This can be useful when we want to generate multiple noise
          shares at once.
  
      Returns:
        The record with local noise added.
      """
      # Round up the noise as the TF discrete Gaussian sampler only takes
      # integer noise stddevs for now.
      ceil_local_stddev = tf.cast(tf.math.ceil(local_stddev), tf.int32)
  
      def add_noise(v):
          # Adds an extra dimension for `shares` number of draws.
          shape = tf.concat([[shares], tf.shape(v)], axis=0)
          dgauss_noise = (
              discrete_gaussian_utils.sample_discrete_gaussian(
                  scale=ceil_local_stddev, shape=shape, dtype=v.dtype
              )
          )
          # Sum across the number of noise shares and add it.
          noised_v = v + tf.reduce_sum(dgauss_noise, axis=0)
          # Set shape as TF shape inference may fail due to custom noise sampler.
          noised_v.set_shape(v.shape.as_list())
          return noised_v
  
      return tf.nest.map_structure(add_noise, record)
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/distributed_discrete_gaussian_query.py
imports: import collections
  import dp_accounting
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import discrete_gaussian_utils
  from tensorflow_privacy.privacy.dp_query import dp_query
label_desc: Use image node_id 4 for calling the DistributedDiscreteGaussianSumQuery obj's underlying member method code with example usage: obj._add_local_noise(record, local_stddev, shares) and returns: tf, noised_v