class_docstr: Implements dp_query for accurate range queries using tree aggregation.
  
  Implements a variant of the tree aggregation protocol from. "Is interaction
  necessary for distributed private learning?. Adam Smith, Abhradeep Thakurta,
  Jalaj Upadhyay." Builds a tree on top of the input record and adds noise to
  the tree for differential privacy. Any range query can be decomposed into the
  sum of O(log(n)) nodes in the tree compared to O(n) when using a histogram.
  Improves efficiency and reduces noise scale.
class_docstr_tok: ["Implements","dp_query","for","accurate","range","queries","using","tree","aggregation",".","Implements","a","variant","of","the","tree","aggregation","protocol","from",".","``","Is","interaction","necessary","for","distributed","private","learning","?",".","Adam","Smith",",","Abhradeep","Thakurta",",","Jalaj","Upadhyay",".","''","Builds","a","tree","on","top","of","the","input","record","and","adds","noise","to","the","tree","for","differential","privacy",".","Any","range","query","can","be","decomposed","into","the","sum","of","O","(","log","(","n",")",")","nodes","in","the","tree","compared","to","O","(","n",")","when","using","a","histogram",".","Improves","efficiency","and","reduces","noise","scale","."]
docstr: Implements `tensorflow_privacy.DPQuery.get_noised_result`.
  
  This function re-constructs the `tf.RaggedTensor` from the flattened tree
  output by `preprocess_records.`
  
  Args:
    sample_state: A `tf.Tensor` for the flattened tree.
    global_state: The global state of the protocol.
  
  Returns:
    A `tf.RaggedTensor` representing the tree.
docstr_tok: ["Implements","`","tensorflow_privacy.DPQuery.get_noised_result","`",".","This","function","re-constructs","the","`","tf.RaggedTensor","`","from","the","flattened","tree","output","by","`","preprocess_records.","`","Args",":","sample_state",":","A","`","tf.Tensor","`","for","the","flattened","tree",".","global_state",":","The","global","state","of","the","protocol",".","Returns",":","A","`","tf.RaggedTensor","`","representing","the","tree","."]
code: def get_noised_result(self, sample_state, global_state):
      """Implements `tensorflow_privacy.DPQuery.get_noised_result`.
  
      This function re-constructs the `tf.RaggedTensor` from the flattened tree
      output by `preprocess_records.`
  
      Args:
        sample_state: A `tf.Tensor` for the flattened tree.
        global_state: The global state of the protocol.
  
      Returns:
        A `tf.RaggedTensor` representing the tree.
      """
      # The [0] is needed because of how tf.RaggedTensor.from_two_splits works.
      # print(tf.RaggedTensor.from_row_splits(values=[3, 1, 4, 1, 5, 9, 2, 6],
      #                                       row_splits=[0, 4, 4, 7, 8, 8]))
      # <tf.RaggedTensor [[3, 1, 4, 1], [], [5, 9, 2], [6], []]>
      # This part is not written in tensorflow and will be executed on the server
      # side instead of the client side if used with
      # tff.aggregators.DifferentiallyPrivateFactory for federated learning.
      (
          sample_state,
          inner_query_state,
          _,
      ) = self._inner_query.get_noised_result(
          sample_state, global_state.inner_query_state
      )
      new_global_state = TreeRangeSumQuery.GlobalState(
          arity=global_state.arity, inner_query_state=inner_query_state
      )
  
      row_splits = [0] + [
          (self._arity ** (x + 1) - 1) // (self._arity - 1)
          for x in range(
              math.floor(math.log(sample_state.shape[0], self._arity))
              + 1
          )
      ]
      tree = tf.RaggedTensor.from_row_splits(
          values=sample_state, row_splits=row_splits
      )
      event = dp_accounting.UnsupportedDpEvent()
      return tree, new_global_state, event
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/tree_range_query.py
imports: import distutils
  import math
  from typing import Any, NamedTuple, Optional
  import dp_accounting
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import distributed_discrete_gaussian_query
  from tensorflow_privacy.privacy.dp_query import dp_query
  from tensorflow_privacy.privacy.dp_query import gaussian_query
label_desc: Use image node_id 6 for calling the TreeRangeSumQuery obj's underlying member method code with example usage: obj.get_noised_result(sample_state, global_state) and returns: tree,  new_global_state,  event