code: def pairwise_distance(X, Y=None, metric="riemann", squared=False):
      """Pairwise distance matrix.
  
      Compute the matrix of distances between pairs of elements of X and Y.
  
      Parameters
      ----------
      X : ndarray, shape (n_matrices_X, n, n)
          First set of matrices.
      Y : None | ndarray, shape (n_matrices_Y, n, n), default=None
          Second set of matrices. If None, Y is set to X.
      metric : string, default='riemann'
          The metric for distance, can be: 'euclid', 'harmonic', 'kullback',
          'kullback_right', 'kullback_sym', 'logdet', 'logeuclid', 'riemann',
          'wasserstein', or a callable function.
      squared : bool, default False
          Return squared distances.
  
          .. versionadded:: 0.5
  
      Returns
      -------
      dist : ndarray, shape (n_matrices_X, n_matrices_X) or (n_matrices_X, \
              n_matrices_Y)
          Distances between pairs of elements of X if Y is None, or between
          elements of X and Y.
  
      See Also
      --------
      distance
      """
      if metric == "euclid":
          return _pairwise_distance_euclid(X, Y=Y, squared=squared)
      elif metric == "harmonic":
          return _pairwise_distance_harmonic(X, Y=Y, squared=squared)
      elif metric == "logeuclid":
          return _pairwise_distance_logeuclid(X, Y=Y, squared=squared)
      elif metric == "riemann":
          return _pairwise_distance_riemann(X, Y=Y, squared=squared)
  
      n_matrices_X, _, _ = X.shape
  
      # compute full pairwise matrix for non-symmetric metrics
      if Y is None and metric in ["kullback", "kullback_right"]:
          Y = X
  
      if Y is None:
          dist = np.zeros((n_matrices_X, n_matrices_X))
          for i in range(n_matrices_X):
              for j in range(i + 1, n_matrices_X):
                  dist[i, j] = distance(
                      X[i], X[j], metric, squared=squared
                  )
          dist += dist.T
      else:
          n_matrices_Y, _, _ = Y.shape
          dist = np.empty((n_matrices_X, n_matrices_Y))
          for i in range(n_matrices_X):
              for j in range(n_matrices_Y):
                  dist[i, j] = distance(
                      X[i], Y[j], metric, squared=squared
                  )
  
      return dist
  
imports: import numpy
  from scipy.linalg import eigvalsh, solve
  from sklearn.metrics import euclidean_distances
  from .base import logm, sqrtm, invsqrtm
label_desc: Use image node_id 18 for calling a global function with example usage: pairwise_distance(X, Y, metric, squared) and returns: dist, _pairwise_distance_euclid, _pairwise_distance_harmonic, _pairwise_distance_logeuclid, _pairwise_distance_riemann