code: def _labels_inertia(
      X,
      x_squared_norms,
      centers,
      precompute_distances=True,
      distances=None,
  ):
      """E step of the K-means EM algorithm.
  
      Compute the labels and the inertia of the given samples and centers.
      This will compute the distances in-place.
  
      Parameters
      ----------
      X: float64 array-like or CSR sparse matrix, shape (n_samples, n_features)
          The input samples to assign to the labels.
  
      x_squared_norms: array, shape (n_samples,)
          Precomputed squared euclidean norm of each data point, to speed up
          computations.
  
      centers: float array, shape (k, n_features)
          The cluster centers.
  
      precompute_distances : boolean, default: True
          Precompute distances (faster but takes more memory).
  
      distances: float array, shape (n_samples,)
          Pre-allocated array to be filled in with each sample's distance
          to the closest center.
  
      Returns
      -------
      labels: int array of shape(n)
          The resulting assignment
  
      inertia : float
          Sum of distances of samples to their closest cluster center.
      """
      n_samples = X.shape[0]
      # set the default value of centers to -1 to be able to detect any anomaly
      # easily
      labels = -np.ones(n_samples, np.int32)
      if distances is None:
          distances = np.zeros(shape=(0,), dtype=X.dtype)
      # distances will be changed in-place
      if sp.issparse(X):
          inertia = _k_means._assign_labels_csr(
              X, x_squared_norms, centers, labels, distances=distances
          )
      else:
          if precompute_distances:
              return _labels_inertia_precompute_dense(
                  X, x_squared_norms, centers, distances
              )
          inertia = _k_means._assign_labels_array(
              X, x_squared_norms, centers, labels, distances=distances
          )
      return labels, inertia
  
imports: import warnings
  import numpy
  import scipy.sparse
  from ..base import BaseEstimator, ClusterMixin, TransformerMixin
  from ..metrics.pairwise import euclidean_distances
  from ..metrics.pairwise import pairwise_distances_argmin_min
  from ..utils.extmath import row_norms, squared_norm
  from ..utils.sparsefuncs_fast import assign_rows_csr
  from ..utils.sparsefuncs import mean_variance_axis
  from ..utils.fixes import astype
  from ..utils import check_array
  from ..utils import check_random_state
  from ..utils import as_float_array
  from ..utils import gen_batches
  from ..utils.validation import check_is_fitted
  from ..utils.validation import FLOAT_DTYPES
  from ..utils.random import choice
  from ..externals.joblib import Parallel
  from ..externals.joblib import delayed
  from ..externals.six import string_types
  from .None import _k_means
  from ._k_means_elkan import k_means_elkan
label_desc: Use image node_id 8 for calling a global function with example usage: _labels_inertia(X, x_squared_norms, centers, precompute_distances, distances) and returns: labels,  inertia, _labels_inertia_precompute_dense