code: def _class_means(X, y):
      """Compute class means.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          Input data.
  
      y : array-like of shape (n_samples,) or (n_samples, n_targets)
          Target values.
  
      Returns
      -------
      means : array-like of shape (n_classes, n_features)
          Class means.
      """
      xp, is_array_api_compliant = get_namespace(X)
      classes, y = xp.unique_inverse(y)
      means = xp.zeros(
          (classes.shape[0], X.shape[1]),
          device=device(X),
          dtype=X.dtype,
      )
  
      if is_array_api_compliant:
          for i in range(classes.shape[0]):
              means[i, :] = xp.mean(X[y == i], axis=0)
      else:
          # TODO: Explore the choice of using bincount + add.at as it seems sub optimal
          # from a performance-wise
          cnt = np.bincount(y)
          np.add.at(means, y, X)
          means /= cnt[:, None]
      return means
  
imports: import warnings
  from numbers import Integral, Real
  import numpy
  import scipy.linalg
  from scipy import linalg
  from .base import BaseEstimator, ClassifierMixin, ClassNamePrefixFeaturesOutMixin, TransformerMixin, _fit_context
  from .covariance import empirical_covariance, ledoit_wolf, shrunk_covariance
  from .linear_model._base import LinearClassifierMixin
  from .preprocessing import StandardScaler
  from .utils._array_api import _expit, device, get_namespace, size
  from .utils._param_validation import HasMethods, Interval, StrOptions
  from .utils.extmath import softmax
  from .utils.multiclass import check_classification_targets, unique_labels
  from .utils.validation import check_is_fitted
label_desc: Use image node_id 2 for calling a global function with example usage: _class_means(X, y) and returns: means