code: def _check_fitted_model(km, n_clusters, n_features, true_labels):
      # check that the number of clusters centers and distinct labels match
      # the expectation
      centers = km.cluster_centers_
      assert centers.shape == (n_clusters, n_features)
  
      labels = km.labels_.fetch()
      assert np.unique(labels).shape[0] == n_clusters
  
      # check that the labels assignment are perfect (up to a permutation)
      assert v_measure_score(true_labels, labels) == 1.0
      assert km.inertia_ > 0.0
  
      # check error on dataset being too small
      assert_raise_message(
          ValueError,
          "n_samples=1 should be >= n_clusters=%d" % km.n_clusters,
          km.fit,
          [[0.0, 1.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 7 for calling a global function with example usage: _check_fitted_model(km, n_clusters, n_features, true_labels) without return types