code: def kmeans_plusplus(
      X,
      n_clusters,
      *,
      sample_weight=None,
      x_squared_norms=None,
      random_state=None,
      n_local_trials=None,
  ):
      """Init n_clusters seeds according to k-means++.
  
      .. versionadded:: 0.24
  
      Parameters
      ----------
      X : {array-like, sparse matrix} of shape (n_samples, n_features)
          The data to pick seeds from.
  
      n_clusters : int
          The number of centroids to initialize.
  
      sample_weight : array-like of shape (n_samples,), default=None
          The weights for each observation in `X`. If `None`, all observations
          are assigned equal weight. `sample_weight` is ignored if `init`
          is a callable or a user provided array.
  
          .. versionadded:: 1.3
  
      x_squared_norms : array-like of shape (n_samples,), default=None
          Squared Euclidean norm of each data point.
  
      random_state : int or RandomState instance, default=None
          Determines random number generation for centroid initialization. Pass
          an int for reproducible output across multiple function calls.
          See :term:`Glossary <random_state>`.
  
      n_local_trials : int, default=None
          The number of seeding trials for each center (except the first),
          of which the one reducing inertia the most is greedily chosen.
          Set to None to make the number of trials depend logarithmically
          on the number of seeds (2+log(k)) which is the recommended setting.
          Setting to 1 disables the greedy cluster selection and recovers the
          vanilla k-means++ algorithm which was empirically shown to work less
          well than its greedy variant.
  
      Returns
      -------
      centers : ndarray of shape (n_clusters, n_features)
          The initial centers for k-means.
  
      indices : ndarray of shape (n_clusters,)
          The index location of the chosen centers in the data array X. For a
          given index and center, X[index] = center.
  
      Notes
      -----
      Selects initial cluster centers for k-mean clustering in a smart way
      to speed up convergence. see: Arthur, D. and Vassilvitskii, S.
      "k-means++: the advantages of careful seeding". ACM-SIAM symposium
      on Discrete algorithms. 2007
  
      Examples
      --------
  
      >>> from sklearn.cluster import kmeans_plusplus
      >>> import numpy as np
      >>> X = np.array([[1, 2], [1, 4], [1, 0],
      ...               [10, 2], [10, 4], [10, 0]])
      >>> centers, indices = kmeans_plusplus(X, n_clusters=2, random_state=0)
      >>> centers
      array([[10,  2],
             [ 1,  0]])
      >>> indices
      array([3, 2])
      """
      # Check data
      check_array(
          X, accept_sparse="csr", dtype=[np.float64, np.float32]
      )
      sample_weight = _check_sample_weight(
          sample_weight, X, dtype=X.dtype
      )
  
      if X.shape[0] < n_clusters:
          raise ValueError(
              f"n_samples={X.shape[0]} should be >= n_clusters={n_clusters}."
          )
  
      # Check parameters
      if x_squared_norms is None:
          x_squared_norms = row_norms(X, squared=True)
      else:
          x_squared_norms = check_array(
              x_squared_norms, dtype=X.dtype, ensure_2d=False
          )
  
      if x_squared_norms.shape[0] != X.shape[0]:
          raise ValueError(
              f"The length of x_squared_norms {x_squared_norms.shape[0]} should "
              f"be equal to the length of n_samples {X.shape[0]}."
          )
  
      random_state = check_random_state(random_state)
  
      # Call private k-means++
      centers, indices = _kmeans_plusplus(
          X,
          n_clusters,
          x_squared_norms,
          sample_weight,
          random_state,
          n_local_trials,
      )
  
      return centers, indices
  
imports: import warnings
  from abc import ABC, abstractmethod
  from numbers import Integral, Real
  import numpy
  import scipy.sparse
  from ..base import BaseEstimator, ClassNamePrefixFeaturesOutMixin, ClusterMixin, TransformerMixin, _fit_context
  from ..exceptions import ConvergenceWarning
  from ..metrics.pairwise import _euclidean_distances, euclidean_distances
  from ..utils import check_array, check_random_state
  from ..utils._openmp_helpers import _openmp_effective_n_threads
  from ..utils._param_validation import Hidden, Interval, StrOptions, validate_params
  from ..utils.extmath import row_norms, stable_cumsum
  from ..utils.fixes import threadpool_info, threadpool_limits
  from ..utils.sparsefuncs import mean_variance_axis
  from ..utils.sparsefuncs_fast import assign_rows_csr
  from ..utils.validation import _check_sample_weight, _is_arraylike_not_scalar, check_is_fitted
  from ._k_means_common import CHUNK_SIZE, _inertia_dense, _inertia_sparse, _is_same_clustering
  from ._k_means_elkan import elkan_iter_chunked_dense, elkan_iter_chunked_sparse, init_bounds_dense, init_bounds_sparse
  from ._k_means_lloyd import lloyd_iter_chunked_dense, lloyd_iter_chunked_sparse
  from ._k_means_minibatch import _minibatch_update_dense, _minibatch_update_sparse
label_desc: Use image node_id 1 for calling a global function with example usage: kmeans_plusplus(X, n_clusters) and returns: centers,  indices