code: def matthews_corrcoef(y_true, y_pred, *, sample_weight=None):
      """Compute the Matthews correlation coefficient (MCC).
  
      The Matthews correlation coefficient is used in machine learning as a
      measure of the quality of binary and multiclass classifications. It takes
      into account true and false positives and negatives and is generally
      regarded as a balanced measure which can be used even if the classes are of
      very different sizes. The MCC is in essence a correlation coefficient value
      between -1 and +1. A coefficient of +1 represents a perfect prediction, 0
      an average random prediction and -1 an inverse prediction.  The statistic
      is also known as the phi coefficient. [source: Wikipedia]
  
      Binary and multiclass labels are supported.  Only in the binary case does
      this relate to information about true and false positives and negatives.
      See references below.
  
      Read more in the :ref:`User Guide <matthews_corrcoef>`.
  
      Parameters
      ----------
      y_true : array-like of shape (n_samples,)
          Ground truth (correct) target values.
  
      y_pred : array-like of shape (n_samples,)
          Estimated targets as returned by a classifier.
  
      sample_weight : array-like of shape (n_samples,), default=None
          Sample weights.
  
          .. versionadded:: 0.18
  
      Returns
      -------
      mcc : float
          The Matthews correlation coefficient (+1 represents a perfect
          prediction, 0 an average random prediction and -1 and inverse
          prediction).
  
      References
      ----------
      .. [1] :doi:`Baldi, Brunak, Chauvin, Andersen and Nielsen, (2000). Assessing the
         accuracy of prediction algorithms for classification: an overview.
         <10.1093/bioinformatics/16.5.412>`
  
      .. [2] `Wikipedia entry for the Matthews Correlation Coefficient
         <https://en.wikipedia.org/wiki/Matthews_correlation_coefficient>`_.
  
      .. [3] `Gorodkin, (2004). Comparing two K-category assignments by a
          K-category correlation coefficient
          <https://www.sciencedirect.com/science/article/pii/S1476927104000799>`_.
  
      .. [4] `Jurman, Riccadonna, Furlanello, (2012). A Comparison of MCC and CEN
          Error Measures in MultiClass Prediction
          <https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0041882>`_.
  
      Examples
      --------
      >>> from sklearn.metrics import matthews_corrcoef
      >>> y_true = [+1, +1, +1, -1]
      >>> y_pred = [+1, -1, +1, +1]
      >>> matthews_corrcoef(y_true, y_pred)
      -0.33...
      """
      y_type, y_true, y_pred = _check_targets(y_true, y_pred)
      check_consistent_length(y_true, y_pred, sample_weight)
      if y_type not in {"binary", "multiclass"}:
          raise ValueError("%s is not supported" % y_type)
  
      lb = LabelEncoder()
      lb.fit(np.hstack([y_true, y_pred]))
      y_true = lb.transform(y_true)
      y_pred = lb.transform(y_pred)
  
      C = confusion_matrix(y_true, y_pred, sample_weight=sample_weight)
      t_sum = C.sum(axis=1, dtype=np.float64)
      p_sum = C.sum(axis=0, dtype=np.float64)
      n_correct = np.trace(C, dtype=np.float64)
      n_samples = p_sum.sum()
      cov_ytyp = n_correct * n_samples - np.dot(t_sum, p_sum)
      cov_ypyp = n_samples**2 - np.dot(p_sum, p_sum)
      cov_ytyt = n_samples**2 - np.dot(t_sum, t_sum)
  
      if cov_ypyp * cov_ytyt == 0:
          return 0.0
      else:
          return cov_ytyp / np.sqrt(cov_ytyt * cov_ypyp)
  
imports: import warnings
  from numbers import Integral, Real
  import numpy
  from scipy.sparse import coo_matrix, csr_matrix
  from scipy.special import xlogy
  from ..exceptions import UndefinedMetricWarning
  from ..preprocessing import LabelBinarizer, LabelEncoder
  from ..utils import assert_all_finite, check_array, check_consistent_length, column_or_1d
  from ..utils._array_api import _union1d, _weighted_sum, get_namespace
  from ..utils._param_validation import Interval, Options, StrOptions, validate_params
  from ..utils.extmath import _nanaverage
  from ..utils.multiclass import type_of_target, unique_labels
  from ..utils.sparsefuncs import count_nonzero
  from ..utils.validation import _check_pos_label_consistency, _num_samples
label_desc: Use image node_id 8 for calling a global function with example usage: matthews_corrcoef(y_true, y_pred) and returns: int, unknown