docstr: Build 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 item's value is slightly slower.
         It is O(lg capacity) instead of O(1).
      b) user has access to an efficient ( O(log segment size) )
         `reduce` operation which reduces `operation` over
         a contiguous subsequence of items in the array.
  Paramters
  ---------
  capacity: int
      Total size of the array - must be a power of two.
  operation: lambda obj, obj -> obj
      and operation for combining elements (eg. sum, max)
      must form a mathematical group together with the set of
      possible values for array elements (i.e. be associative)
  neutral_element: obj
      neutral element for the operation above. eg. float('-inf')
      for max and 0 for sum.
docstr_tok: ["Build","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","item","'s","value","is","slightly","slower",".","It","is","O","(","lg","capacity",")","instead","of","O","(","1",")",".","b",")","user","has","access","to","an","efficient","(","O","(","log","segment","size",")",")","`","reduce","`","operation","which","reduces","`","operation","`","over","a","contiguous","subsequence","of","items","in","the","array",".","Paramters","--","--","--","--","-","capacity",":","int","Total","size","of","the","array","-","must","be","a","power","of","two",".","operation",":","lambda","obj",",","obj","-",">","obj","and","operation","for","combining","elements","(","eg",".","sum",",","max",")","must","form","a","mathematical","group","together","with","the","set","of","possible","values","for","array","elements","(","i.e",".","be","associative",")","neutral_element",":","obj","neutral","element","for","the","operation","above",".","eg",".","float","(","'-inf","'",")","for","max","and","0","for","sum","."]
code: def __init__(self, capacity, operation, neutral_element):
      """Build 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 item's value is slightly slower.
             It is O(lg capacity) instead of O(1).
          b) user has access to an efficient ( O(log segment size) )
             `reduce` operation which reduces `operation` over
             a contiguous subsequence of items in the array.
      Paramters
      ---------
      capacity: int
          Total size of the array - must be a power of two.
      operation: lambda obj, obj -> obj
          and operation for combining elements (eg. sum, max)
          must form a mathematical group together with the set of
          possible values for array elements (i.e. be associative)
      neutral_element: obj
          neutral element for the operation above. eg. float('-inf')
          for max and 0 for sum.
      """
      assert (
          capacity > 0 and capacity & (capacity - 1) == 0
      ), "capacity must be positive and a power of 2."
      self._capacity = capacity
      self._value = [neutral_element for _ in range(2 * capacity)]
      self._operation = operation
  
imports: import argparse
  import operator
  import os
  import random
  import time
  import gym
  import matplotlib.pyplot
  import numpy
  import tensorflow
  import tensorlayer
label_desc: Use image node_id 1 to create a new SegmentTree object from inherited base classes: object with example: obj = SegmentTree(capacity, operation, neutral_element)