code: def test_k_means_explicit_init_shape(setup):
      # test for sensible errors when giving explicit init
      # with wrong number of features or clusters
      rnd = np.random.RandomState(0)
      X = rnd.normal(size=(40, 3))
  
      # mismatch of number of features
      km = KMeans(
          n_init=1, init=X[:, :2], n_clusters=len(X), algorithm="elkan"
      )
      msg = "does not match the number of features of the data"
      with pytest.raises(ValueError, match=msg):
          km.fit(X)
      # for callable init
      km = KMeans(
          n_init=1,
          init=lambda X_, k, random_state: X_[:, :2],
          n_clusters=len(X),
          algorithm="elkan",
      )
      with pytest.raises(ValueError, match=msg):
          km.fit(X)
      # mismatch of number of clusters
      msg = "does not match the number of clusters"
      km = KMeans(
          n_init=1, init=X[:2, :], n_clusters=3, algorithm="elkan"
      )
      with pytest.raises(ValueError, match=msg):
          km.fit(X)
      # for callable init
      km = KMeans(
          n_init=1,
          init=lambda X_, k, random_state: X_[:2, :],
          n_clusters=3,
          algorithm="elkan",
      )
      with pytest.raises(ValueError, match=msg):
          km.fit(X)
  
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 10 for calling a global function with example usage: test_k_means_explicit_init_shape(setup) without return types