class_docstr: !
  @brief Represents balanced static KD-tree that does not provide services to add and remove nodes after
          initialization.
  @details In the term KD tree, k denotes the dimensionality of the space being represented. Each data point is
            represented as a node in the k-d tree in the form of a record of type node.
  
  There is an example how to create KD-tree:
  @code
      from pyclustering.container.kdtree import kdtree_balanced, kdtree_visualizer
      from pyclustering.utils import read_sample
      from pyclustering.samples.definitions import FCPS_SAMPLES
  
      sample = read_sample(FCPS_SAMPLES.SAMPLE_LSUN)
      tree_instance = kdtree_balanced(sample)
  
      kdtree_visualizer(tree_instance).visualize()
  @endcode
  
  Output result of the example above - figure 1.
  @image html kd_tree_balanced_lsun.png "Fig. 1. Balanced KD-tree for sample 'Lsun'."
  
  @see kdtree
class_docstr_tok: ["!","@","brief","Represents","balanced","static","KD-tree","that","does","not","provide","services","to","add","and","remove","nodes","after","initialization",".","@","details","In","the","term","KD","tree",",","k","denotes","the","dimensionality","of","the","space","being","represented",".","Each","data","point","is","represented","as","a","node","in","the","k-d","tree","in","the","form","of","a","record","of","type","node",".","There","is","an","example","how","to","create","KD-tree",":","@","code","from","pyclustering.container.kdtree","import","kdtree_balanced",",","kdtree_visualizer","from","pyclustering.utils","import","read_sample","from","pyclustering.samples.definitions","import","FCPS_SAMPLES","sample","=","read_sample","(","FCPS_SAMPLES.SAMPLE_LSUN",")","tree_instance","=","kdtree_balanced","(","sample",")","kdtree_visualizer","(","tree_instance",")",".visualize","(",")","@","endcode","Output","result","of","the","example","above","-","figure","1",".","@","image","html","kd_tree_balanced_lsun.png","``","Fig",".","1",".","Balanced","KD-tree","for","sample","'Lsun","'",".","''","@","see","kdtree"]
docstr: !
  @brief Initializes balanced static KD-tree.
  
  @param[in] points (array_like): Points that should be used to build KD-tree.
  @param[in] payloads (array_like): Payload of each point in `points`.
docstr_tok: ["!","@","brief","Initializes","balanced","static","KD-tree",".","@","param","[","in","]","points","(","array_like",")",":","Points","that","should","be","used","to","build","KD-tree",".","@","param","[","in","]","payloads","(","array_like",")",":","Payload","of","each","point","in","`","points","`","."]
code: def __init__(self, points, payloads=None):
      """!
      @brief Initializes balanced static KD-tree.
  
      @param[in] points (array_like): Points that should be used to build KD-tree.
      @param[in] payloads (array_like): Payload of each point in `points`.
  
      """
  
      if points is None:
          self._length = 0
          self._dimension = 0
          self._point_comparator = None
          self._root = None
          return
  
      self._dimension = len(points[0])
      self._point_comparator = self._create_point_comparator(
          type(points[0])
      )
      self._length = 0
  
      nodes = []
      for i in range(len(points)):
          payload = None
          if payloads is not None:
              payload = payloads[i]
  
          nodes.append(node(points[i], payload, None, None, -1, None))
  
      self._root = self.__create_tree(nodes, None, 0)
  
imports: import numpy
  import matplotlib.pyplot
  from pyclustering.utils import euclidean_distance_square, find_left_element
label_desc: Use image node_id 1 to create a new kdtree_balanced object  with example: obj = kdtree_balanced(points, payloads)