class_docstr: A Segment Tree data structure.
  
  https://en.wikipedia.org/wiki/Segment_tree
  
  Can be used as regular array, but with two important differences:
  
    a) Setting an item's value is slightly slower. It is O(lg capacity),
       instead of O(1).
    b) Offers efficient `reduce` operation which reduces the tree's values
       over some specified contiguous subsequence of items in the array.
       Operation could be e.g. min/max/sum.
  
  The data is stored in a list, where the length is 2 * capacity.
  The second half of the list stores the actual values for each index, so if
  capacity=8, values are stored at indices 8 to 15. The first half of the
  array contains the reduced-values of the different (binary divided)
  segments, e.g. (capacity=4):
  0=not used
  1=reduced-value over all elements (array indices 4 to 7).
  2=reduced-value over array indices (4 and 5).
  3=reduced-value over array indices (6 and 7).
  4-7: values of the tree.
  NOTE that the values of the tree are accessed by indices starting at 0, so
  `tree[0]` accesses `internal_array[4]` in the above example.
class_docstr_tok: ["A","Segment","Tree","data","structure",".","https",":","\/\/en.wikipedia.org\/wiki\/Segment_tree","Can","be","used","as","regular","array",",","but","with","two","important","differences",":","a",")","Setting","an","item","'s","value","is","slightly","slower",".","It","is","O","(","lg","capacity",")",",","instead","of","O","(","1",")",".","b",")","Offers","efficient","`","reduce","`","operation","which","reduces","the","tree","'s","values","over","some","specified","contiguous","subsequence","of","items","in","the","array",".","Operation","could","be","e.g",".","min\/max\/sum",".","The","data","is","stored","in","a","list",",","where","the","length","is","2","*","capacity",".","The","second","half","of","the","list","stores","the","actual","values","for","each","index",",","so","if","capacity=8",",","values","are","stored","at","indices","8","to","15",".","The","first","half","of","the","array","contains","the","reduced-values","of","the","different","(","binary","divided",")","segments",",","e.g",".","(","capacity=4",")",":","0=not","used","1=reduced-value","over","all","elements","(","array","indices","4","to","7",")",".","2=reduced-value","over","array","indices","(","4","and","5",")",".","3=reduced-value","over","array","indices","(","6","and","7",")",".","4-7",":","values","of","the","tree",".","NOTE","that","the","values","of","the","tree","are","accessed","by","indices","starting","at","0",",","so","`","tree","[","0","]","`","accesses","`","internal_array","[","4","]","`","in","the","above","example","."]
code: def __getitem__(self, idx: int) -> Any:
      assert 0 <= idx < self.capacity
      return self.value[idx + self.capacity]
  
file_path: ray/rllib/execution/segment_tree.py
imports: import operator
  from typing import Any, Optional
label_desc: Use image node_id 4 for calling the SegmentTree obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: self