docstr: Helper function to compute the distance difference of every triplet in the
  space yielded by the basis set.
docstr_tok: ["Helper","function","to","compute","the","distance","difference","of","every","triplet","in","the","space","yielded","by","the","basis","set","."]
code: def _compute_dist_diff(self, triplets, X, basis):
      """
      Helper function to compute the distance difference of every triplet in the
      space yielded by the basis set.
      """
      # Transformation of data by the basis set
      XB = np.matmul(X, basis.T)
  
      n_triplets = triplets.shape[0]
      # get all positive and negative pairs with lowest index first
      # np.array (2*n_triplets,2)
      triplets_pairs_sorted = np.sort(
          np.vstack((triplets[:, [0, 1]], triplets[:, [0, 2]])),
          kind="stable",
      )
      # calculate all unique pairs and their indices
      uniqPairs, indices = np.unique(
          triplets_pairs_sorted, return_inverse=True, axis=0
      )
      # calculate L2 distance acording to bases only for unique pairs
      dist = np.square(XB[uniqPairs[:, 0], :] - XB[uniqPairs[:, 1], :])
  
      # return the diference of distances between all positive and negative
      # pairs
      return dist[indices[:n_triplets]] - dist[indices[n_triplets:]]
  
imports: from __future__ import print_function, absolute_import, division
  import numpy
  from .base_metric import _TripletsClassifierMixin, MahalanobisMixin
  from ._util import components_from_metric
  from sklearn.base import TransformerMixin
  from .constraints import Constraints
  from sklearn.preprocessing import normalize
  from sklearn.neighbors import NearestNeighbors
  from sklearn.cluster import KMeans
  from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
  from sklearn.utils import check_array, check_random_state
  import warnings
label_desc: Use image node_id 3 for calling the _BaseSCML obj's underlying member method code with example usage: obj._compute_dist_diff(triplets, X, basis) and returns: unknown