class_docstr: kd-tree for quick nearest-neighbor lookup.
  
  This class provides an index into a set of k-dimensional points
  which can be used to rapidly look up the nearest neighbors of any
  point.
  
  Parameters
  ----------
  data : array_like, shape (n,m)
      The n data points of dimension m to be indexed. This array is
      not copied unless this is necessary to produce a contiguous
      array of doubles, and so modifying this data will result in
      bogus results. The data are also copied if the kd-tree is built
      with copy_data=True.
  leafsize : positive int, optional
      The number of points at which the algorithm switches over to
      brute-force.  Default: 10.
  compact_nodes : bool, optional
      If True, the kd-tree is built to shrink the hyperrectangles to
      the actual data range. This usually gives a more compact tree that
      is robust against degenerated input data and gives faster queries
      at the expense of longer build time. Default: True.
  copy_data : bool, optional
      If True the data is always copied to protect the kd-tree against
      data corruption. Default: False.
  balanced_tree : bool, optional
      If True, the median is used to split the hyperrectangles instead of
      the midpoint. This usually gives a more compact tree and
      faster queries at the expense of longer build time. Default: True.
  boxsize : array_like or scalar, optional
      Apply a m-d toroidal topology to the KDTree.. The topology is generated
      by :math:`x_i + n_i L_i` where :math:`n_i` are integers and :math:`L_i`
      is the boxsize along i-th dimension. The input data shall be wrapped
      into :math:`[0, L_i)`. A ValueError is raised if any of the data is
      outside of this bound.
  
  Notes
  -----
  The algorithm used is described in Maneewongvatana and Mount 1999.
  The general idea is that the kd-tree is a binary tree, each of whose
  nodes represents an axis-aligned hyperrectangle. Each node specifies
  an axis and splits the set of points based on whether their coordinate
  along that axis is greater than or less than a particular value.
  
  During construction, the axis and splitting point are chosen by the
  "sliding midpoint" rule, which ensures that the cells do not all
  become long and thin.
  
  The tree can be queried for the r closest neighbors of any given point
  (optionally returning only those within some maximum distance of the
  point). It can also be queried, with a substantial gain in efficiency,
  for the r approximate closest neighbors.
  
  For large dimensions (20 is already large) do not expect this to run
  significantly faster than brute force. High-dimensional nearest-neighbor
  queries are a substantial open problem in computer science.
  
  Attributes
  ----------
  data : ndarray, shape (n,m)
      The n data points of dimension m to be indexed. This array is
      not copied unless this is necessary to produce a contiguous
      array of doubles. The data are also copied if the kd-tree is built
      with `copy_data=True`.
  leafsize : positive int
      The number of points at which the algorithm switches over to
      brute-force.
  m : int
      The dimension of a single data-point.
  n : int
      The number of data points.
  maxes : ndarray, shape (m,)
      The maximum value in each dimension of the n data points.
  mins : ndarray, shape (m,)
      The minimum value in each dimension of the n data points.
  size : int
      The number of nodes in the tree.
docstr: Find all pairs of points between `self` and `other` whose distance is
  at most r.
  
  Parameters
  ----------
  other : KDTree instance
      The tree containing points to search against.
  r : float
      The maximum distance, has to be positive.
  p : float, optional
      Which Minkowski norm to use.  `p` has to meet the condition
      ``1 <= p <= infinity``.
  eps : float, optional
      Approximate search.  Branches of the tree are not explored
      if their nearest points are further than ``r/(1+eps)``, and
      branches are added in bulk if their furthest points are nearer
      than ``r * (1+eps)``.  `eps` has to be non-negative.
  
  Returns
  -------
  results : list of lists
      For each element ``self.data[i]`` of this tree, ``results[i]`` is a
      list of the indices of its neighbors in ``other.data``.
  
  Examples
  --------
  You can search all pairs of points between two kd-trees within a distance:
  
  >>> import matplotlib.pyplot as plt
  >>> import numpy as np
  >>> from scipy.spatial import KDTree
  >>> rng = np.random.default_rng()
  >>> points1 = rng.random((15, 2))
  >>> points2 = rng.random((15, 2))
  >>> plt.figure(figsize=(6, 6))
  >>> plt.plot(points1[:, 0], points1[:, 1], "xk", markersize=14)
  >>> plt.plot(points2[:, 0], points2[:, 1], "og", markersize=14)
  >>> kd_tree1 = KDTree(points1)
  >>> kd_tree2 = KDTree(points2)
  >>> indexes = kd_tree1.query_ball_tree(kd_tree2, r=0.2)
  >>> for i in range(len(indexes)):
  ...     for j in indexes[i]:
  ...         plt.plot([points1[i, 0], points2[j, 0]],
  ...             [points1[i, 1], points2[j, 1]], "-r")
  >>> plt.show()
docstr_tok: ["Find","all","pairs","of","points","between","`","self","`","and","`","other","`","whose","distance","is","at","most","r.","Parameters","--","--","--","--","--","other",":","KDTree","instance","The","tree","containing","points","to","search","against",".","r",":","float","The","maximum","distance",",","has","to","be","positive",".","p",":","float",",","optional","Which","Minkowski","norm","to","use",".","`","p","`","has","to","meet","the","condition","``","1","<","=","p","<","=","infinity","``",".","eps",":","float",",","optional","Approximate","search",".","Branches","of","the","tree","are","not","explored","if","their","nearest","points","are","further","than","``","r\/","(","1+eps",")","``",",","and","branches","are","added","in","bulk","if","their","furthest","points","are","nearer","than","``","r","*","(","1+eps",")","``",".","`","eps","`","has","to","be","non-negative",".","Returns","--","--","--","-","results",":","list","of","lists","For","each","element","``","self.data","[","i","]","``","of","this","tree",",","``","results","[","i","]","``","is","a","list","of","the","indices","of","its","neighbors","in","``","other.data","``",".","Examples","--","--","--","--","You","can","search","all","pairs","of","points","between","two","kd-trees","within","a","distance",":",">",">",">","import","matplotlib.pyplot","as","plt",">",">",">","import","numpy","as","np",">",">",">","from","scipy.spatial","import","KDTree",">",">",">","rng","=","np.random.default_rng","(",")",">",">",">","points1","=","rng.random","(","(","15",",","2",")",")",">",">",">","points2","=","rng.random","(","(","15",",","2",")",")",">",">",">","plt.figure","(","figsize=","(","6",",","6",")",")",">",">",">","plt.plot","(","points1","[",":",",","0","]",",","points1","[",":",",","1","]",",","``","xk","''",",","markersize=14",")",">",">",">","plt.plot","(","points2","[",":",",","0","]",",","points2","[",":",",","1","]",",","``","og","''",",","markersize=14",")",">",">",">","kd_tree1","=","KDTree","(","points1",")",">",">",">","kd_tree2","=","KDTree","(","points2",")",">",">",">","indexes","=","kd_tree1.query_ball_tree","(","kd_tree2",",","r=0.2",")",">",">",">","for","i","in","range","(","len","(","indexes",")",")",":","...","for","j","in","indexes","[","i","]",":","...","plt.plot","(","[","points1","[","i",",","0","]",",","points2","[","j",",","0","]","]",",","...","[","points1","[","i",",","1","]",",","points2","[","j",",","1","]","]",",","``","-r","''",")",">",">",">","plt.show","(",")"]
code: def query_ball_tree(self, other, r, p=2.0, eps=0):
      """
      Find all pairs of points between `self` and `other` whose distance is
      at most r.
  
      Parameters
      ----------
      other : KDTree instance
          The tree containing points to search against.
      r : float
          The maximum distance, has to be positive.
      p : float, optional
          Which Minkowski norm to use.  `p` has to meet the condition
          ``1 <= p <= infinity``.
      eps : float, optional
          Approximate search.  Branches of the tree are not explored
          if their nearest points are further than ``r/(1+eps)``, and
          branches are added in bulk if their furthest points are nearer
          than ``r * (1+eps)``.  `eps` has to be non-negative.
  
      Returns
      -------
      results : list of lists
          For each element ``self.data[i]`` of this tree, ``results[i]`` is a
          list of the indices of its neighbors in ``other.data``.
  
      Examples
      --------
      You can search all pairs of points between two kd-trees within a distance:
  
      >>> import matplotlib.pyplot as plt
      >>> import numpy as np
      >>> from scipy.spatial import KDTree
      >>> rng = np.random.default_rng()
      >>> points1 = rng.random((15, 2))
      >>> points2 = rng.random((15, 2))
      >>> plt.figure(figsize=(6, 6))
      >>> plt.plot(points1[:, 0], points1[:, 1], "xk", markersize=14)
      >>> plt.plot(points2[:, 0], points2[:, 1], "og", markersize=14)
      >>> kd_tree1 = KDTree(points1)
      >>> kd_tree2 = KDTree(points2)
      >>> indexes = kd_tree1.query_ball_tree(kd_tree2, r=0.2)
      >>> for i in range(len(indexes)):
      ...     for j in indexes[i]:
      ...         plt.plot([points1[i, 0], points2[j, 0]],
      ...             [points1[i, 1], points2[j, 1]], "-r")
      >>> plt.show()
  
      """
      return super().query_ball_tree(other, r, p, eps)
  
imports: import numpy
  from ._ckdtree import cKDTree, cKDTreeNode
label_desc: Use image node_id 5 for calling the KDTree obj's underlying member method code with example usage: obj.query_ball_tree(other, r, p, eps) and returns: super