docstr: Test whether `_build_tree_from_leaf` will output the correct tree.
docstr_tok: ["Test","whether","`","_build_tree_from_leaf","`","will","output","the","correct","tree","."]
code: def test_build_tree_from_leaf(self, leaf_nodes_size, arity, dtype):
      """Test whether `_build_tree_from_leaf` will output the correct tree."""
  
      leaf_nodes = tf.cast(tf.range(leaf_nodes_size), dtype)
      depth = math.ceil(math.log(leaf_nodes_size, arity)) + 1
  
      tree = tree_range_query._build_tree_from_leaf(leaf_nodes, arity)
  
      self.assertEqual(depth, tree.shape[0])
  
      for layer in range(depth):
          reverse_depth = tree.shape[0] - layer - 1
          span_size = arity**reverse_depth
          for idx in range(arity**layer):
              left = idx * span_size
              right = (idx + 1) * span_size
              expected_value = sum(leaf_nodes[left:right])
              self.assertEqual(tree[layer][idx], expected_value)
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/tree_range_query_test.py
imports: import math
  from absl.testing import parameterized
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import tree_range_query
label_desc: Use image node_id 1 for calling the BuildTreeTest obj's underlying member method code with example usage: obj.test_build_tree_from_leaf(leaf_nodes_size, arity, dtype) without return types