code: def class_distinctiveness(
      X, y, exponent=1, metric="riemann", return_num_denom=False
  ):
      r"""Measure class distinctiveness between classes of SPD matrices.
  
      For two class problem, the class distinctiveness between class A
      and B on the manifold of SPD matrices is quantified as [1]_:
  
      .. math::
          \mathrm{classDis}(A, B, p) = \frac{d \left(\bar{X}^{A},
          \bar{X}^{B}\right)^p}
          {\frac{1}{2} \left( \sigma_{X^{A}}^p + \sigma_{X^{B}}^p \right)}
  
      where :math:`\bar{X}^{K}` is the center of class K, ie the mean of matrices
      from class K (see :func:`pyriemann.utils.mean.mean_covariance`) and
      :math:`\sigma_{X^{K}}` is the class dispersion, ie the mean of distances
      between matrices from class K and their center of class
      :math:`\bar{X}^{K}`:
  
      .. math::
          \sigma_{X^{K}}^p = \frac{1}{m} \sum_{i=1}^m d
          \left(X_i, \bar{X}^{K}\right)^p
  
      For more than two classes, it is quantified as:
  
      .. math::
          \mathrm{classDis}\left(\left\{K_{j}\right\}, p\right) =
          \frac{\sum_{j=1}^{c} d\left(\bar{X}^{K_{j}}, \tilde{X}\right)^p}
          {\sum_{j=1}^{c} \sigma_{X^{K_{j}}}^p}
  
      where :math:`\tilde{X}` is the mean of centers of class of all :math:`c`
      classes and :math:`p` is the exponentiation of the distance measure
      named exponent at the input of this function.
  
      Parameters
      ----------
      X : ndarray, shape (n_matrices, n_channels, n_channels)
          Set of SPD matrices.
      y : ndarray, shape (n_matrices,)
          Labels for each matrix.
      exponent : int, default=1
          Parameter for exponentiation of distances, corresponding to p in the
          above equations:
  
          - exponent = 1 gives the formula originally defined in [1]_;
          - exponent = 2 gives the Fisher criterion generalized on the manifold,
            ie the ratio of the variance between the classes to the variance
            within the classes.
      metric : string | dict, default='riemann'
          The type of metric used for centroid and distance estimation.
          See `mean_covariance` for the list of supported metric.
          The metric could be a dict with two keys, `mean` and `distance` in
          order to pass different metrics for the centroid estimation and the
          distance estimation. The original equation of class distinctiveness
          in [1]_ uses 'riemann' for both the centroid estimation and the
          distance estimation but you can customize other metrics with your
          interests.
      return_num_denom : bool, default=False
          Whether to return numerator and denominator of class_dis.
  
      Returns
      -------
      class_dis : float
          Class distinctiveness value.
      num : float
          Numerator value of class_dis. Returned only if return_num_denom is
          True.
      denom : float
          Denominator value of class_dis. Returned only if return_num_denom is
          True.
  
      Notes
      -----
      .. versionadded:: 0.4
  
      References
      ----------
      .. [1] `Defining and quantifying users’ mental imagery-based
         BCI skills: a first step
         <https://hal.archives-ouvertes.fr/hal-01846434/>`_
         F. Lotte, and C. Jeunet. Journal of neural engineering,
         15(4), 046030, 2018.
      """
  
      metric_mean, metric_dist = _check_metric(metric)
      classes = np.unique(y)
      if len(classes) <= 1:
          raise ValueError("X must contain at least two classes")
  
      means = np.array(
          [
              mean_covariance(X[y == ll], metric=metric_mean)
              for ll in classes
          ]
      )
  
      if len(classes) == 2:
          num = (
              distance(means[0], means[1], metric=metric_dist)
              ** exponent
          )
          denom = 0.5 * _get_within(
              X, y, means, classes, exponent, metric_dist
          )
  
      else:
          mean_all = mean_covariance(means, metric=metric_mean)
          dists_between = [
              distance(m, mean_all, metric=metric_dist) ** exponent
              for m in means
          ]
          num = np.sum(dists_between)
          denom = _get_within(
              X, y, means, classes, exponent, metric_dist
          )
  
      class_dis = num / denom
  
      if return_num_denom:
          return class_dis, num, denom
      else:
          return class_dis
  
imports: import functools
  import numpy
  from sklearn.base import BaseEstimator, ClassifierMixin, TransformerMixin
  from sklearn.svm import SVC
  from sklearn.utils.extmath import softmax
  from sklearn.linear_model import LogisticRegression
  from sklearn.pipeline import make_pipeline
  from joblib import Parallel, delayed
  import warnings
  from .utils.kernel import kernel
  from .utils.mean import mean_covariance, mean_power
  from .utils.distance import distance
  from .tangentspace import FGDA, TangentSpace
label_desc: Use image node_id 4 for calling a global function with example usage: class_distinctiveness(X, y, exponent, metric, return_num_denom) and returns: class_dis,  num,  denom, class_dis