code: def merge_nodes(values, partition_tree):
      """This merges the two clustered leaf nodes with the smallest total value."""
      M = partition_tree.shape[0] + 1
  
      ptind = 0
      min_val = np.inf
      for i in range(partition_tree.shape[0]):
          ind1 = int(partition_tree[i, 0])
          ind2 = int(partition_tree[i, 1])
          if ind1 < M and ind2 < M:
              val = np.abs(values[ind1]) + np.abs(values[ind2])
              if val < min_val:
                  min_val = val
                  ptind = i
                  # print("ptind", ptind, min_val)
  
      ind1 = int(partition_tree[ptind, 0])
      ind2 = int(partition_tree[ptind, 1])
      if ind1 > ind2:
          tmp = ind1
          ind1 = ind2
          ind2 = tmp
  
      partition_tree_new = partition_tree.copy()
      for i in range(partition_tree_new.shape[0]):
          i0 = int(partition_tree_new[i, 0])
          i1 = int(partition_tree_new[i, 1])
          if i0 == ind2:
              partition_tree_new[i, 0] = ind1
          elif i0 > ind2:
              partition_tree_new[i, 0] -= 1
              if i0 == ptind + M:
                  partition_tree_new[i, 0] = ind1
              elif i0 > ptind + M:
                  partition_tree_new[i, 0] -= 1
  
          if i1 == ind2:
              partition_tree_new[i, 1] = ind1
          elif i1 > ind2:
              partition_tree_new[i, 1] -= 1
              if i1 == ptind + M:
                  partition_tree_new[i, 1] = ind1
              elif i1 > ptind + M:
                  partition_tree_new[i, 1] -= 1
      partition_tree_new = np.delete(partition_tree_new, ptind, axis=0)
  
      # update the counts to be correct
      fill_counts(partition_tree_new)
  
      return partition_tree_new, ind1, ind2
  
file_path: shap/shap/plots/_utils.py
imports: import matplotlib.pyplot
  import numpy
  from ..None import Explanation
  from ..utils import OpChain
  from .None import colors
label_desc: Use image node_id 4 for calling a global function with example usage: merge_nodes(values, partition_tree) and returns: partition_tree_new,  ind1,  ind2