class_docstr: A tree which can be used as a min/max heap or a sum tree
  Add or update item value - O(log N)
  Sampling an item - O(log N)
docstr: Given a value between 0 and the tree sum, return the object which this value is in it's range.
  For example, if we have 3 leaves: 10, 20, 30, and val=35, this will return the 3rd leaf, by accumulating
  leaves by their order until getting to 35. This allows sampling leaves according to their proportional
  probability.
  :param val: a value within the range 0 and the tree sum
  :return: the index of the resulting leaf in the tree, its probability and
           the object itself
docstr_tok: ["Given","a","value","between","0","and","the","tree","sum",",","return","the","object","which","this","value","is","in","it","'s","range",".","For","example",",","if","we","have","3","leaves",":","10",",","20",",","30",",","and","val=35",",","this","will","return","the","3rd","leaf",",","by","accumulating","leaves","by","their","order","until","getting","to","35",".","This","allows","sampling","leaves","according","to","their","proportional","probability",".",":","param","val",":","a","value","within","the","range","0","and","the","tree","sum",":","return",":","the","index","of","the","resulting","leaf","in","the","tree",",","its","probability","and","the","object","itself"]
code: def get_element_by_partial_sum(
      self, val: float
  ) -> Tuple[int, float, Any]:
      """
      Given a value between 0 and the tree sum, return the object which this value is in it's range.
      For example, if we have 3 leaves: 10, 20, 30, and val=35, this will return the 3rd leaf, by accumulating
      leaves by their order until getting to 35. This allows sampling leaves according to their proportional
      probability.
      :param val: a value within the range 0 and the tree sum
      :return: the index of the resulting leaf in the tree, its probability and
               the object itself
      """
      node_idx = self._retrieve(0, val)
      leaf_idx = node_idx - self.size + 1
      data_value = self.tree[node_idx]
      data = self.data[leaf_idx]
  
      return leaf_idx, data_value, data
  
imports: import operator
  import random
  from enum import Enum
  from typing import List, Tuple, Any
  import numpy
  from rl_coach.core_types import Transition
  from rl_coach.memories.memory import MemoryGranularity
  from rl_coach.memories.non_episodic.experience_replay import ExperienceReplayParameters, ExperienceReplay
  from rl_coach.schedules import Schedule, ConstantSchedule
label_desc: Use image node_id 7 for calling the SegmentTree obj's underlying member method code with example usage: obj.get_element_by_partial_sum(val) and returns: leaf_idx,  data_value,  data