code: def _append_singleton_leaf_node(
      Z, p, n, level, lvs, ivl, leaf_label_func, i, labels
  ):
      # If the leaf id structure is not None and is a list then the caller
      # to dendrogram has indicated that cluster id's corresponding to the
      # leaf nodes should be recorded.
  
      if lvs is not None:
          lvs.append(int(i))
  
      # If leaf node labels are to be displayed...
      if ivl is not None:
          # If a leaf_label_func has been provided, the label comes from the
          # string returned from the leaf_label_func, which is a function
          # passed to dendrogram.
          if leaf_label_func:
              ivl.append(leaf_label_func(int(i)))
          else:
              # Otherwise, if the dendrogram caller has passed a labels list
              # for the leaf nodes, use it.
              if labels is not None:
                  ivl.append(labels[int(i - n)])
              else:
                  # Otherwise, use the id as the label for the leaf.x
                  ivl.append(str(int(i)))
  
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._disjoint_set import DisjointSet
label_desc: Use image node_id 41 for calling a global function with example usage: _append_singleton_leaf_node(Z, p, n, level, lvs, ivl, leaf_label_func, i, labels) without return types