class_docstr: Interface for differentially private query mechanisms.
  
  Differential privacy is achieved by processing records to bound sensitivity,
  accumulating the processed records (usually by summing them) and then
  adding noise to the aggregated result. The process can be repeated to compose
  applications of the same mechanism, possibly with different parameters.
  
  The DPQuery interface specifies a functional approach to this process. A
  global state maintains state that persists across applications of the
  mechanism. For each application, the following steps are performed:
  
  1. Use the global state to derive parameters to use for the next sample of
     records.
  2. Initialize a sample state that will accumulate processed records.
  3. For each record:
     a. Process the record.
     b. Accumulate the record into the sample state.
  4. Get the result of the mechanism, possibly updating the global state to use
     in the next application.
  5. Derive metrics from the global state.
  
  Here is an example using the GaussianSumQuery. Assume there is some function
  records_for_round(round) that returns an iterable of records to use on some
  round.
  
  ```
  dp_query = tensorflow_privacy.GaussianSumQuery(
      l2_norm_clip=1.0, stddev=1.0)
  global_state = dp_query.initial_global_state()
  
  for round in range(num_rounds):
    sample_params = dp_query.derive_sample_params(global_state)
    sample_state = dp_query.initial_sample_state()
    for record in records_for_round(round):
      sample_state = dp_query.accumulate_record(
          sample_params, sample_state, record)
  
    result, global_state = dp_query.get_noised_result(
        sample_state, global_state)
    metrics = dp_query.derive_metrics(global_state)
  
    # Do something with result and metrics...
  ```
class_docstr_tok: ["Interface","for","differentially","private","query","mechanisms",".","Differential","privacy","is","achieved","by","processing","records","to","bound","sensitivity",",","accumulating","the","processed","records","(","usually","by","summing","them",")","and","then","adding","noise","to","the","aggregated","result",".","The","process","can","be","repeated","to","compose","applications","of","the","same","mechanism",",","possibly","with","different","parameters",".","The","DPQuery","interface","specifies","a","functional","approach","to","this","process",".","A","global","state","maintains","state","that","persists","across","applications","of","the","mechanism",".","For","each","application",",","the","following","steps","are","performed",":","1",".","Use","the","global","state","to","derive","parameters","to","use","for","the","next","sample","of","records",".","2",".","Initialize","a","sample","state","that","will","accumulate","processed","records",".","3",".","For","each","record",":","a",".","Process","the","record",".","b",".","Accumulate","the","record","into","the","sample","state",".","4",".","Get","the","result","of","the","mechanism",",","possibly","updating","the","global","state","to","use","in","the","next","application",".","5",".","Derive","metrics","from","the","global","state",".","Here","is","an","example","using","the","GaussianSumQuery",".","Assume","there","is","some","function","records_for_round","(","round",")","that","returns","an","iterable","of","records","to","use","on","some","round",".","``","`","dp_query","=","tensorflow_privacy.GaussianSumQuery","(","l2_norm_clip=1.0",",","stddev=1.0",")","global_state","=","dp_query.initial_global_state","(",")","for","round","in","range","(","num_rounds",")",":","sample_params","=","dp_query.derive_sample_params","(","global_state",")","sample_state","=","dp_query.initial_sample_state","(",")","for","record","in","records_for_round","(","round",")",":","sample_state","=","dp_query.accumulate_record","(","sample_params",",","sample_state",",","record",")","result",",","global_state","=","dp_query.get_noised_result","(","sample_state",",","global_state",")","metrics","=","dp_query.derive_metrics","(","global_state",")","#","Do","something","with","result","and","metrics","...","``","`"]
docstr: Gets the query result after all records of sample have been accumulated.
  
  The global state can also be updated for use in the next application of the
  DP mechanism.
  
  Args:
    sample_state: The sample state after all records have been accumulated. In
      standard DP-SGD training, the accumulated sum of clipped microbatch
      gradients (in the special case of microbatches of size 1, the clipped
      per-example gradients).
    global_state: The global state, storing long-term privacy bookkeeping.
  
  Returns:
    A tuple `(result, new_global_state, event)` where:
      * `result` is the result of the query,
      * `new_global_state` is the updated global state, and
      * `event` is the `DpEvent` that occurred.
    In standard DP-SGD training, the result is a gradient update comprising a
    noised average of the clipped gradients in the sample state---with the
    noise and averaging performed in a manner that guarantees differential
    privacy.
docstr_tok: ["Gets","the","query","result","after","all","records","of","sample","have","been","accumulated",".","The","global","state","can","also","be","updated","for","use","in","the","next","application","of","the","DP","mechanism",".","Args",":","sample_state",":","The","sample","state","after","all","records","have","been","accumulated",".","In","standard","DP-SGD","training",",","the","accumulated","sum","of","clipped","microbatch","gradients","(","in","the","special","case","of","microbatches","of","size","1",",","the","clipped","per-example","gradients",")",".","global_state",":","The","global","state",",","storing","long-term","privacy","bookkeeping",".","Returns",":","A","tuple","`","(","result",",","new_global_state",",","event",")","`","where",":","*","`","result","`","is","the","result","of","the","query",",","*","`","new_global_state","`","is","the","updated","global","state",",","and","*","`","event","`","is","the","`","DpEvent","`","that","occurred",".","In","standard","DP-SGD","training",",","the","result","is","a","gradient","update","comprising","a","noised","average","of","the","clipped","gradients","in","the","sample","state","--","-with","the","noise","and","averaging","performed","in","a","manner","that","guarantees","differential","privacy","."]
code: def get_noised_result(self, sample_state, global_state):
      """Gets the query result after all records of sample have been accumulated.
  
      The global state can also be updated for use in the next application of the
      DP mechanism.
  
      Args:
        sample_state: The sample state after all records have been accumulated. In
          standard DP-SGD training, the accumulated sum of clipped microbatch
          gradients (in the special case of microbatches of size 1, the clipped
          per-example gradients).
        global_state: The global state, storing long-term privacy bookkeeping.
  
      Returns:
        A tuple `(result, new_global_state, event)` where:
          * `result` is the result of the query,
          * `new_global_state` is the updated global state, and
          * `event` is the `DpEvent` that occurred.
        In standard DP-SGD training, the result is a gradient update comprising a
        noised average of the clipped gradients in the sample state---with the
        noise and averaging performed in a manner that guarantees differential
        privacy.
      """
      pass
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/dp_query.py
imports: import abc
  import collections
  import tensorflow
label_desc: Use image node_id 8 for calling the DPQuery obj's underlying member method code with example usage: obj.get_noised_result(sample_state, global_state) without return types