code: def test_k_means_init(setup):
      # non centered, sparse centers to check the
      centers = np.array(
          [
              [0.0, 5.0, 0.0, 0.0, 0.0],
              [1.0, 1.0, 4.0, 0.0, 0.0],
              [1.0, 0.0, 0.0, 5.0, 1.0],
          ]
      )
      n_samples = 100
      n_clusters, n_features = centers.shape
      X, true_labels = make_blobs(
          n_samples=n_samples,
          centers=centers,
          cluster_std=1.0,
          random_state=42,
      )
      X_csr = sp.csr_matrix(X)
      for data in [X, X_csr]:
          for init in [
              "random",
              "k-means++",
              "k-means||",
              centers.copy(),
          ]:
              data = mt.tensor(data, chunk_size=50)
              km = KMeans(
                  init=init,
                  n_clusters=n_clusters,
                  random_state=42,
                  n_init=1,
                  algorithm="elkan",
              )
              km.fit(data)
              _check_fitted_model(
                  km, n_clusters, n_features, true_labels
              )
  
      X = mt.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]])
      kmeans = KMeans(
          n_clusters=2, random_state=0, n_init=1, init="k-means||"
      ).fit(X)
      assert sorted(kmeans.cluster_centers_.fetch().tolist()) == sorted(
          [[10.0, 2.0], [1.0, 2.0]]
      )
  
imports: import sys
  from io import StringIO
  import numpy
  import pytest
  import scipy.sparse
  from ....None import tensor
  from ....core import TileableGraphBuilder, TileableGraph, ChunkGraphBuilder
  from ....config import options
  from ..None import KMeans, k_means
  from .._kmeans import _init_centroids
label_desc: Use image node_id 8 for calling a global function with example usage: test_k_means_init(setup) without return types