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: Accumulates a single record into the sample state.
  
  This is a helper method that simply delegates to `preprocess_record` and
  `accumulate_preprocessed_record` for the common case when both of those
  functions run on a single device. Typically this will be a simple sum.
  
  Args:
    params: The parameters for the sample. In standard DP-SGD training, the
      clipping norm for the sample's microbatch gradients (i.e., a maximum
      norm magnitude to which each gradient is clipped)
    sample_state: The current sample state. In standard DP-SGD training, the
      accumulated sum of previous clipped microbatch gradients.
    record: The record to accumulate. In standard DP-SGD training, the
      gradient computed for the examples in one microbatch, which may be the
      gradient for just one example (for size 1 microbatches).
  
  Returns:
    The updated sample state. In standard DP-SGD training, the set of
    previous microbatch gradients with the addition of the record argument.
docstr_tok: ["Accumulates","a","single","record","into","the","sample","state",".","This","is","a","helper","method","that","simply","delegates","to","`","preprocess_record","`","and","`","accumulate_preprocessed_record","`","for","the","common","case","when","both","of","those","functions","run","on","a","single","device",".","Typically","this","will","be","a","simple","sum",".","Args",":","params",":","The","parameters","for","the","sample",".","In","standard","DP-SGD","training",",","the","clipping","norm","for","the","sample","'s","microbatch","gradients","(","i.e.",",","a","maximum","norm","magnitude","to","which","each","gradient","is","clipped",")","sample_state",":","The","current","sample","state",".","In","standard","DP-SGD","training",",","the","accumulated","sum","of","previous","clipped","microbatch","gradients",".","record",":","The","record","to","accumulate",".","In","standard","DP-SGD","training",",","the","gradient","computed","for","the","examples","in","one","microbatch",",","which","may","be","the","gradient","for","just","one","example","(","for","size","1","microbatches",")",".","Returns",":","The","updated","sample","state",".","In","standard","DP-SGD","training",",","the","set","of","previous","microbatch","gradients","with","the","addition","of","the","record","argument","."]
code: def accumulate_record(self, params, sample_state, record):
      """Accumulates a single record into the sample state.
  
      This is a helper method that simply delegates to `preprocess_record` and
      `accumulate_preprocessed_record` for the common case when both of those
      functions run on a single device. Typically this will be a simple sum.
  
      Args:
        params: The parameters for the sample. In standard DP-SGD training, the
          clipping norm for the sample's microbatch gradients (i.e., a maximum
          norm magnitude to which each gradient is clipped)
        sample_state: The current sample state. In standard DP-SGD training, the
          accumulated sum of previous clipped microbatch gradients.
        record: The record to accumulate. In standard DP-SGD training, the
          gradient computed for the examples in one microbatch, which may be the
          gradient for just one example (for size 1 microbatches).
  
      Returns:
        The updated sample state. In standard DP-SGD training, the set of
        previous microbatch gradients with the addition of the record argument.
      """
      preprocessed_record = self.preprocess_record(params, record)
      return self.accumulate_preprocessed_record(
          sample_state, preprocessed_record
      )
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/dp_query.py
imports: import abc
  import collections
  import tensorflow
label_desc: Use image node_id 6 for calling the DPQuery obj's underlying member method code with example usage: obj.accumulate_record(params, sample_state, record) and returns: self