code: def _predict(self, X, sample_weight=None):
      """Predict the closest cluster each sample in X belongs to.
  
      In the vector quantization literature, `cluster_centers_` is called
      the code book and each value returned by `predict` is the index of
      the closest code in the code book.
  
      Parameters
      ----------
      X : {array-like, sparse matrix}, shape = [n_samples, n_features]
         New data to predict.
  
      sample_weight : array-like, shape (n_samples,), optional
          The weights for each observation in X. If None, all observations
          are assigned equal weight (default: None)
  
      Returns
      -------
      labels : array, shape [n_samples,]
          Index of the cluster each sample belongs to.
      """
      check_is_fitted(self)
  
      X = self._check_test_data(X)
  
      _patching_status = PatchingConditionsChain(
          "sklearn.cluster.KMeans.predict"
      )
      _dal_ready = _patching_status.and_conditions(
          [
              (
                  sample_weight is None,
                  "Sample weights are not supported.",
              ),
              (
                  hasattr(X, "__array__"),
                  "X does not have '__array__' attribute.",
              ),
          ]
      )
  
      _patching_status.write_log()
      if _dal_ready:
          return _daal4py_k_means_predict(
              X, self.n_clusters, self.cluster_centers_
          )[0]
      x_squared_norms = row_norms(X, squared=True)
      return _labels_inertia(
          X, sample_weight, x_squared_norms, self.cluster_centers_
      )[0]
  
imports: import numpy
  from scipy import sparse
  from sklearn.utils import check_array, check_random_state
  from sklearn.utils.sparsefuncs import mean_variance_axis
  from sklearn.utils.validation import _num_samples, check_is_fitted
  import warnings
  from sklearn.cluster import KMeans
  from sklearn.utils.extmath import row_norms
  import daal4py
  from .._device_offload import support_usm_ndarray
  from .._utils import PatchingConditionsChain, control_n_jobs, daal_check_version, getFPType, run_with_n_jobs
label_desc: Use image node_id 7 for calling a global function with example usage: _predict(X, sample_weight) and returns: _labels_inertia, _daal4py_k_means_predict