class_docstr: Mahalanobis metric learning algorithms.
  
  Algorithm that learns a Mahalanobis (pseudo) distance :math:`d_M(x, x')`,
  defined between two column vectors :math:`x` and :math:`x'` by: :math:`d_M(x,
  x') = \sqrt{(x-x')^T M (x-x')}`, where :math:`M` is a learned symmetric
  positive semi-definite (PSD) matrix. The metric between points can then be
  expressed as the euclidean distance between points embedded in a new space
  through a linear transformation. Indeed, the above matrix can be decomposed
  into the product of two transpose matrices (through SVD or Cholesky
  decomposition): :math:`d_M(x, x')^2 = (x-x')^T M (x-x') = (x-x')^T L^T L
  (x-x') = (L x - L x')^T (L x- L x')`
  
  Attributes
  ----------
  components_ : `numpy.ndarray`, shape=(n_components, n_features)
    The learned linear transformation ``L``.
class_docstr_tok: ["Mahalanobis","metric","learning","algorithms",".","Algorithm","that","learns","a","Mahalanobis","(","pseudo",")","distance",":","math",":","`","d_M","(","x",",","x","'",")","`",",","defined","between","two","column","vectors",":","math",":","`","x","`","and",":","math",":","`","x","'","`","by",":",":","math",":","`","d_M","(","x",",","x","'",")","=","\\sqrt","{","(","x-x","'",")","^T","M","(","x-x","'",")","}","`",",","where",":","math",":","`","M","`","is","a","learned","symmetric","positive","semi-definite","(","PSD",")","matrix",".","The","metric","between","points","can","then","be","expressed","as","the","euclidean","distance","between","points","embedded","in","a","new","space","through","a","linear","transformation",".","Indeed",",","the","above","matrix","can","be","decomposed","into","the","product","of","two","transpose","matrices","(","through","SVD","or","Cholesky","decomposition",")",":",":","math",":","`","d_M","(","x",",","x","'",")","^2","=","(","x-x","'",")","^T","M","(","x-x","'",")","=","(","x-x","'",")","^T","L^T","L","(","x-x","'",")","=","(","L","x","-","L","x","'",")","^T","(","L","x-","L","x","'",")","`","Attributes","--","--","--","--","--","components_",":","`","numpy.ndarray","`",",","shape=","(","n_components",",","n_features",")","The","learned","linear","transformation","``","L","``","."]
docstr: Returns the learned Mahalanobis distance between pairs.
  
  This distance is defined as: :math:`d_M(x, x') = \sqrt{(x-x')^T M (x-x')}`
  where ``M`` is the learned Mahalanobis matrix, for every pair of points
  ``x`` and ``x'``. This corresponds to the euclidean distance between
  embeddings of the points in a new space, obtained through a linear
  transformation. Indeed, we have also: :math:`d_M(x, x') = \sqrt{(x_e -
  x_e')^T (x_e- x_e')}`, with :math:`x_e = L x` (See
  :class:`MahalanobisMixin`).
  
  Parameters
  ----------
  pairs : array-like, shape=(n_pairs, 2, n_features) or (n_pairs, 2)
    3D Array of pairs to score, with each row corresponding to two points,
    for 2D array of indices of pairs if the metric learner uses a
    preprocessor.
  
  Returns
  -------
  scores : `numpy.ndarray` of shape=(n_pairs,)
    The learned Mahalanobis distance for every pair.
  
  See Also
  --------
  get_metric : a method that returns a function to compute the metric between
    two points. The difference with `pair_distance` is that it works on two
    1D arrays and cannot use a preprocessor. Besides, the returned function
    is independent of the metric learner and hence is  not modified if the
    metric learner is.
  
  :ref:`mahalanobis_distances` : The section of the project documentation
    that describes Mahalanobis Distances.
docstr_tok: ["Returns","the","learned","Mahalanobis","distance","between","pairs",".","This","distance","is","defined","as",":",":","math",":","`","d_M","(","x",",","x","'",")","=","\\sqrt","{","(","x-x","'",")","^T","M","(","x-x","'",")","}","`","where","``","M","``","is","the","learned","Mahalanobis","matrix",",","for","every","pair","of","points","``","x","``","and","``","x","'","``",".","This","corresponds","to","the","euclidean","distance","between","embeddings","of","the","points","in","a","new","space",",","obtained","through","a","linear","transformation",".","Indeed",",","we","have","also",":",":","math",":","`","d_M","(","x",",","x","'",")","=","\\sqrt","{","(","x_e","-","x_e","'",")","^T","(","x_e-","x_e","'",")","}","`",",","with",":","math",":","`","x_e","=","L","x","`","(","See",":","class",":","`","MahalanobisMixin","`",")",".","Parameters","--","--","--","--","--","pairs",":","array-like",",","shape=","(","n_pairs",",","2",",","n_features",")","or","(","n_pairs",",","2",")","3D","Array","of","pairs","to","score",",","with","each","row","corresponding","to","two","points",",","for","2D","array","of","indices","of","pairs","if","the","metric","learner","uses","a","preprocessor",".","Returns","--","--","--","-","scores",":","`","numpy.ndarray","`","of","shape=","(","n_pairs",",",")","The","learned","Mahalanobis","distance","for","every","pair",".","See","Also","--","--","--","--","get_metric",":","a","method","that","returns","a","function","to","compute","the","metric","between","two","points",".","The","difference","with","`","pair_distance","`","is","that","it","works","on","two","1D","arrays","and","can","not","use","a","preprocessor",".","Besides",",","the","returned","function","is","independent","of","the","metric","learner","and","hence","is","not","modified","if","the","metric","learner","is",".",":","ref",":","`","mahalanobis_distances","`",":","The","section","of","the","project","documentation","that","describes","Mahalanobis","Distances","."]
code: def pair_distance(self, pairs):
      """
      Returns the learned Mahalanobis distance between pairs.
  
      This distance is defined as: :math:`d_M(x, x') = \\sqrt{(x-x')^T M (x-x')}`
      where ``M`` is the learned Mahalanobis matrix, for every pair of points
      ``x`` and ``x'``. This corresponds to the euclidean distance between
      embeddings of the points in a new space, obtained through a linear
      transformation. Indeed, we have also: :math:`d_M(x, x') = \\sqrt{(x_e -
      x_e')^T (x_e- x_e')}`, with :math:`x_e = L x` (See
      :class:`MahalanobisMixin`).
  
      Parameters
      ----------
      pairs : array-like, shape=(n_pairs, 2, n_features) or (n_pairs, 2)
        3D Array of pairs to score, with each row corresponding to two points,
        for 2D array of indices of pairs if the metric learner uses a
        preprocessor.
  
      Returns
      -------
      scores : `numpy.ndarray` of shape=(n_pairs,)
        The learned Mahalanobis distance for every pair.
  
      See Also
      --------
      get_metric : a method that returns a function to compute the metric between
        two points. The difference with `pair_distance` is that it works on two
        1D arrays and cannot use a preprocessor. Besides, the returned function
        is independent of the metric learner and hence is  not modified if the
        metric learner is.
  
      :ref:`mahalanobis_distances` : The section of the project documentation
        that describes Mahalanobis Distances.
      """
      check_is_fitted(self, ["preprocessor_"])
      pairs = check_input(
          pairs,
          type_of_inputs="tuples",
          preprocessor=self.preprocessor_,
          estimator=self,
          tuple_size=2,
      )
      pairwise_diffs = self.transform(pairs[:, 1, :] - pairs[:, 0, :])
      # (for MahalanobisMixin, the embedding is linear so we can just embed the
      # difference)
      return np.sqrt(np.sum(pairwise_diffs**2, axis=-1))
  
imports: from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.utils.extmath import stable_cumsum
  from sklearn.utils.validation import _is_arraylike, check_is_fitted
  from sklearn.metrics import roc_auc_score, roc_curve, precision_recall_curve
  import numpy
  from abc import ABCMeta, abstractmethod
  from ._util import ArrayIndexer, check_input, validate_vector
  import warnings
label_desc: Use image node_id 3 for calling the MahalanobisMixin obj's underlying member method code with example usage: obj.pair_distance(pairs) and returns: np