class_docstr: A tree node class for representing a cluster.
  
  Leaf nodes correspond to original observations, while non-leaf nodes
  correspond to non-singleton clusters.
  
  The `to_tree` function converts a matrix returned by the linkage
  function into an easy-to-use tree representation.
  
  All parameter names are also attributes.
  
  Parameters
  ----------
  id : int
      The node id.
  left : ClusterNode instance, optional
      The left child tree node.
  right : ClusterNode instance, optional
      The right child tree node.
  dist : float, optional
      Distance for this cluster in the linkage matrix.
  count : int, optional
      The number of samples in this cluster.
  
  See Also
  --------
  to_tree : for converting a linkage matrix ``Z`` into a tree object.
class_docstr_tok: ["A","tree","node","class","for","representing","a","cluster",".","Leaf","nodes","correspond","to","original","observations",",","while","non-leaf","nodes","correspond","to","non-singleton","clusters",".","The","`","to_tree","`","function","converts","a","matrix","returned","by","the","linkage","function","into","an","easy-to-use","tree","representation",".","All","parameter","names","are","also","attributes",".","Parameters","--","--","--","--","--","id",":","int","The","node","id",".","left",":","ClusterNode","instance",",","optional","The","left","child","tree","node",".","right",":","ClusterNode","instance",",","optional","The","right","child","tree","node",".","dist",":","float",",","optional","Distance","for","this","cluster","in","the","linkage","matrix",".","count",":","int",",","optional","The","number","of","samples","in","this","cluster",".","See","Also","--","--","--","--","to_tree",":","for","converting","a","linkage","matrix","``","Z","``","into","a","tree","object","."]
code: def __init__(self, id, left=None, right=None, dist=0, count=1):
      if id < 0:
          raise ValueError("The id must be non-negative.")
      if dist < 0:
          raise ValueError("The distance must be non-negative.")
      if (left is None and right is not None) or (
          left is not None and right is None
      ):
          raise ValueError(
              "Only full or proper binary trees are permitted."
              "  This node has one child."
          )
      if count < 1:
          raise ValueError(
              "A cluster must contain at least one original "
              "observation."
          )
      self.id = id
      self.left = left
      self.right = right
      self.dist = dist
      if self.left is None:
          self.count = count
      else:
          self.count = left.count + right.count
  
imports: import warnings
  import bisect
  from collections import deque
  import numpy
  from .None import _hierarchy, _optimal_leaf_ordering
  import scipy.spatial.distance
  from scipy._lib._array_api import array_namespace, as_xparray, copy
  from scipy._lib._disjoint_set import DisjointSet
label_desc: Use image node_id 1 to create a new ClusterNode object  with example: obj = ClusterNode(id, left, right, dist, count)