class_docstr: Implements DPQuery interface for discrete distributed sum queries.
  
  This implementation is for the distributed queries where the Skellam noise
  is applied locally to a discrete vector that matches the norm bound.
class_docstr_tok: ["Implements","DPQuery","interface","for","discrete","distributed","sum","queries",".","This","implementation","is","for","the","distributed","queries","where","the","Skellam","noise","is","applied","locally","to","a","discrete","vector","that","matches","the","norm","bound","."]
docstr: Check record norm and add noise to the record.
  
  For both L1 and L2 norms we compute a global norm of the provided record.
  Since the record contains int32 tensors we cast them into float32 to
  compute L2 norm. In the end we run three asserts: type, l1, and l2 norms.
  
  Args:
    params: The parameters for the particular sample.
    record: The record to be processed.
  
  Returns:
    A tuple (preprocessed_records, params) where `preprocessed_records` is
      the structure of preprocessed tensors, and params contains sample
      params.
docstr_tok: ["Check","record","norm","and","add","noise","to","the","record",".","For","both","L1","and","L2","norms","we","compute","a","global","norm","of","the","provided","record",".","Since","the","record","contains","int32","tensors","we","cast","them","into","float32","to","compute","L2","norm",".","In","the","end","we","run","three","asserts",":","type",",","l1",",","and","l2","norms",".","Args",":","params",":","The","parameters","for","the","particular","sample",".","record",":","The","record","to","be","processed",".","Returns",":","A","tuple","(","preprocessed_records",",","params",")","where","`","preprocessed_records","`","is","the","structure","of","preprocessed","tensors",",","and","params","contains","sample","params","."]
code: def preprocess_record(self, params, record):
      """Check record norm and add noise to the record.
  
      For both L1 and L2 norms we compute a global norm of the provided record.
      Since the record contains int32 tensors we cast them into float32 to
      compute L2 norm. In the end we run three asserts: type, l1, and l2 norms.
  
      Args:
        params: The parameters for the particular sample.
        record: The record to be processed.
  
      Returns:
        A tuple (preprocessed_records, params) where `preprocessed_records` is
          the structure of preprocessed tensors, and params contains sample
          params.
      """
      record_as_list = tf.nest.flatten(record)
      record_as_float = [tf.cast(x, tf.float32) for x in record_as_list]
      tf.nest.map_structure(
          lambda x: tf.debugging.assert_type(x, tf.int32),
          record_as_list,
      )
      dependencies = [
          tf.debugging.assert_less_equal(
              tf.reduce_sum(
                  [tf.norm(x, ord=1) for x in record_as_list]
              ),
              params.l1_norm_bound,
              message=f"L1 norm exceeds {params.l1_norm_bound}.",
          ),
          tf.debugging.assert_less_equal(
              tf.linalg.global_norm(record_as_float),
              params.l2_norm_bound,
              message=f"Global L2 norm exceeds {params.l2_norm_bound}.",
          ),
      ]
      with tf.control_dependencies(dependencies):
          record = tf.cond(
              tf.equal(params.local_stddev, 0),
              lambda: record,
              lambda: self.add_noise_to_sample(
                  params.local_stddev, record
              ),
          )
          return record
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/distributed_skellam_query.py
imports: import collections
  import dp_accounting
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import dp_query
  from tensorflow_privacy.privacy.dp_query import normalized_query
label_desc: Use image node_id 5 for calling the DistributedSkellamSumQuery obj's underlying member method code with example usage: obj.preprocess_record(params, record) and returns: record