code: def elbow_curve(
      X,
      clf,
      range_n_clusters=None,
      n_jobs=1,
      show_cluster_time=True,
      ax=None,
      n_clusters="deprecated",
  ):
      """Plots elbow curve of different values of K of a clustering algorithm.
  
      Parameters
      ----------
      X : array-like, shape = [n_samples, n_features]:
          Data to cluster, where n_samples is the number of samples and
          n_features is the number of features.
          Refer https://numpy.org/doc/stable/glossary.html#term-array-like
  
      clf
          Clusterer instance that implements ``fit``,``fit_predict``, and
          ``score`` methods, and an ``range_n_clusters`` hyperparameter.
          e.g. :class:`sklearn.cluster.KMeans` instance
  
      range_n_clusters : None or :obj:`list` of int, optional
          List of n_clusters for which to plot the explained variances.
          Defaults to ``[1, 3, 5, 7, 9, 11]``.
  
      n_jobs : int, optional
          Number of jobs to run in parallel. Defaults to 1.
  
      show_cluster_time : bool, optional
          Include plot of time it took to cluster for a particular K.
  
      ax : :class:`matplotlib.axes.Axes`, optional
          The axes upon which to plot the curve. If None, the plot is drawn
          on the current Axes
  
      Returns
      -------
      ax: matplotlib Axes
          Axes containing the plot
  
      Notes
      -----
      .. deprecated:: 0.9
          ``n_clusters`` renamed to ``range_n_clusters`` and will be removed in version
          0.10
  
      Examples
      --------
      .. plot:: ../examples/elbow_curve.py
  
      """
      range_n_clusters = deprecated.parameter_renamed(
          deprecated_in="0.9",
          remove_in="0.10",
          old_name="n_clusters",
          old_value=n_clusters,
          new_name="range_n_clusters",
          new_value=range_n_clusters,
      )
  
      if range_n_clusters is None:
          range_n_clusters = range(1, 10, 2)
      else:
          range_n_clusters = sorted(range_n_clusters)
  
      if not hasattr(clf, "n_clusters"):
          raise TypeError(
              '"n_clusters" attribute not in classifier. '
              "Cannot plot elbow method."
          )
  
      tuples = Parallel(n_jobs=n_jobs)(
          delayed(_clone_and_score_clusterer)(clf, X, i)
          for i in range_n_clusters
      )
      clfs, times = zip(*tuples)
      sum_of_squares = np.absolute(clfs)
      return elbow_curve_from_results(
          range_n_clusters,
          sum_of_squares,
          times if show_cluster_time else None,
          ax=ax,
      )
  
file_path: sklearn-evaluation/src/sklearn_evaluation/plot/clustering.py
imports: import time
  import matplotlib.pyplot
  import numpy
  from sklearn.base import clone
  from sklearn.metrics import silhouette_samples, silhouette_score
  from sklearn.preprocessing import LabelEncoder
  from joblib import Parallel, delayed
  from sklearn_evaluation.telemetry import SKLearnEvaluationLogger
  from ploomber_core.exceptions import modify_exceptions
  from ploomber_core import deprecated
label_desc: Use image node_id 1 for calling a global function with example usage: elbow_curve(X, clf, range_n_clusters, n_jobs, show_cluster_time, ax, n_clusters) and returns: elbow_curve_from_results