code: def test_k_means_results(setup, representation, dtype, algo):
      array_constr = {"dense": np.array, "sparse": sp.csr_matrix}[
          representation
      ]
  
      X = array_constr(
          [[0, 0], [0.5, 0], [0.5, 1], [1, 1]], dtype=dtype
      )
      sample_weight = [
          3,
          1,
          1,
          3,
      ]  # will be rescaled to [1.5, 0.5, 0.5, 1.5]
      init_centers = np.array([[0, 0], [1, 1]], dtype=dtype)
  
      expected_labels = [0, 0, 1, 1]
      expected_inertia = 0.1875
      expected_centers = np.array([[0.125, 0], [0.875, 1]], dtype=dtype)
      expected_n_iter = 2
  
      kmeans = KMeans(
          n_clusters=2, n_init=1, init=init_centers, algorithm=algo
      )
      kmeans.fit(X, sample_weight=sample_weight)
  
      np.testing.assert_array_equal(kmeans.labels_, expected_labels)
      np.testing.assert_almost_equal(kmeans.inertia_, expected_inertia)
      np.testing.assert_array_almost_equal(
          kmeans.cluster_centers_, expected_centers
      )
      assert kmeans.n_iter_ == expected_n_iter
  
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 1 for calling a global function with example usage: test_k_means_results(setup, representation, dtype, algo) without return types