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: Returns an initial state to use for the next sample.
  
  For typical `DPQuery` classes that are aggregated by summation, this should
  return a nested structure of zero tensors of the appropriate shapes, to
  which processed records will be aggregated.
  
  Args:
    template: A nested structure of tensors, TensorSpecs, or numpy arrays used
      as a template to create the initial sample state. It is assumed that the
      leaves of the structure are python scalars or some type that has
      properties `shape` and `dtype`.
  Returns: An initial sample state.
docstr_tok: ["Returns","an","initial","state","to","use","for","the","next","sample",".","For","typical","`","DPQuery","`","classes","that","are","aggregated","by","summation",",","this","should","return","a","nested","structure","of","zero","tensors","of","the","appropriate","shapes",",","to","which","processed","records","will","be","aggregated",".","Args",":","template",":","A","nested","structure","of","tensors",",","TensorSpecs",",","or","numpy","arrays","used","as","a","template","to","create","the","initial","sample","state",".","It","is","assumed","that","the","leaves","of","the","structure","are","python","scalars","or","some","type","that","has","properties","`","shape","`","and","`","dtype","`",".","Returns",":","An","initial","sample","state","."]
code: def initial_sample_state(self, template=None):
      """Returns an initial state to use for the next sample.
  
      For typical `DPQuery` classes that are aggregated by summation, this should
      return a nested structure of zero tensors of the appropriate shapes, to
      which processed records will be aggregated.
  
      Args:
        template: A nested structure of tensors, TensorSpecs, or numpy arrays used
          as a template to create the initial sample state. It is assumed that the
          leaves of the structure are python scalars or some type that has
          properties `shape` and `dtype`.
      Returns: An initial sample state.
      """
      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 3 for calling the DPQuery obj's underlying member method code with example usage: obj.initial_sample_state(template) without return types