code: def plot_dendrogram(model, **kwargs):
      # function copied from sklearn:
      # plot_agglomerative_dendrogram.html
      #
      # Create linkage matrix and then plot the dendrogram
  
      # create the counts of samples under each node
      counts = np.zeros(model.children_.shape[0])
      n_samples = len(model.labels_)
      for i, merge in enumerate(model.children_):
          current_count = 0
          for child_idx in merge:
              if child_idx < n_samples:
                  current_count += 1  # leaf node
              else:
                  current_count += counts[child_idx - n_samples]
          counts[i] = current_count
      linkage_matrix = np.column_stack(
          [model.children_, model.distances_, counts]
      ).astype(float)
  
      # Plot the corresponding dendrogram
      dendrogram(
          linkage_matrix,
          color_threshold=sorted(model.distances_)[-2],
          **kwargs,
      )
  
file_path: pyts/examples/clustering/plot_dtw_boss.py
imports: import itertools
  import numpy
  import matplotlib.pyplot
  from scipy.spatial.distance import euclidean
  from scipy.cluster.hierarchy import dendrogram
  from sklearn.metrics import homogeneity_score
  from sklearn.cluster import AgglomerativeClustering
  from pyts.metrics import dtw, boss
  from pyts.transformation import BOSS
  from pyts.datasets import make_cylinder_bell_funnel
label_desc: Use image node_id 2 for calling a global function with example usage: plot_dendrogram(model) without return types