class_docstr: Tree aggregator to compute accumulated noise in private algorithms.
  
  This class implements the tree aggregation algorithm for noise values to
  efficiently privatize streaming algorithms based on Dwork et al. (2010)
  https://dl.acm.org/doi/pdf/10.1145/1806689.1806787. A buffer at the scale of
  tree depth is maintained and updated when a new conceptual leaf node arrives.
  
  Example usage:
    random_generator = GaussianNoiseGenerator(...)
    tree_aggregator = TreeAggregator(random_generator)
    state = tree_aggregator.init_state()
    for leaf_node_idx in range(total_steps):
      assert leaf_node_idx == get_step_idx(state))
      noise, state = tree_aggregator.get_cumsum_and_update(state)
  
  Attributes:
    value_generator: A `ValueGenerator` or a no-arg function to generate a noise
      value for each tree node.
class_docstr_tok: ["Tree","aggregator","to","compute","accumulated","noise","in","private","algorithms",".","This","class","implements","the","tree","aggregation","algorithm","for","noise","values","to","efficiently","privatize","streaming","algorithms","based","on","Dwork","et","al",".","(","2010",")","https",":","\/\/dl.acm.org\/doi\/pdf\/10.1145\/1806689.1806787",".","A","buffer","at","the","scale","of","tree","depth","is","maintained","and","updated","when","a","new","conceptual","leaf","node","arrives",".","Example","usage",":","random_generator","=","GaussianNoiseGenerator","(","...",")","tree_aggregator","=","TreeAggregator","(","random_generator",")","state","=","tree_aggregator.init_state","(",")","for","leaf_node_idx","in","range","(","total_steps",")",":","assert","leaf_node_idx","==","get_step_idx","(","state",")",")","noise",",","state","=","tree_aggregator.get_cumsum_and_update","(","state",")","Attributes",":","value_generator",":","A","`","ValueGenerator","`","or","a","no-arg","function","to","generate","a","noise","value","for","each","tree","node","."]
docstr: Initialize the aggregator with a noise generator.
  
  Args:
    value_generator: A `ValueGenerator` or a no-arg function to generate a
      noise value for each tree node.
docstr_tok: ["Initialize","the","aggregator","with","a","noise","generator",".","Args",":","value_generator",":","A","`","ValueGenerator","`","or","a","no-arg","function","to","generate","a","noise","value","for","each","tree","node","."]
code: def __init__(
      self, value_generator: Union[ValueGenerator, Callable[[], Any]]
  ):
      """Initialize the aggregator with a noise generator.
  
      Args:
        value_generator: A `ValueGenerator` or a no-arg function to generate a
          noise value for each tree node.
      """
      if isinstance(value_generator, ValueGenerator):
          self.value_generator = value_generator
      else:
          self.value_generator = StatelessValueGenerator(
              value_generator
          )
  
imports: import abc
  import collections
  from typing import Any, Callable, Collection, NamedTuple, Optional, Tuple, Union
  import tensorflow
label_desc: Use image node_id 1 to create a new TreeAggregator object  with example: obj = TreeAggregator(value_generator)