code: def distance_riemann(A, B, squared=False):
      r"""Affine-invariant Riemannian distance between SPD/HPD matrices.
  
      The affine-invariant Riemannian distance between two SPD/HPD matrices
      :math:`\mathbf{A}` and :math:`\mathbf{B}` is [1]_:
  
      .. math::
          d(\mathbf{A},\mathbf{B}) =
          {\left( \sum_i \log(\lambda_i)^2 \right)}^{1/2}
  
      where :math:`\lambda_i` are the joint eigenvalues of :math:`\mathbf{A}` and
      :math:`\mathbf{B}`.
  
      Parameters
      ----------
      A : ndarray, shape (..., n, n)
          First SPD/HPD matrices, at least 2D ndarray.
      B : ndarray, shape (..., n, n)
          Second SPD/HPD matrices, same dimensions as A.
      squared : bool, default False
          Return squared distance.
  
          .. versionadded:: 0.5
  
      Returns
      -------
      d : float or ndarray, shape (...,)
          Affine-invariant Riemannian distance between A and B.
  
      See Also
      --------
      distance
  
      References
      ----------
      .. [1] `A differential geometric approach to the geometric mean of
          symmetric positive-definite matrices
          <https://epubs.siam.org/doi/10.1137/S0895479803436937>`_
          M. Moakher. SIAM J Matrix Anal Appl, 2005, 26 (3), pp. 735-747
      """
      _check_inputs(A, B)
      d2 = (np.log(_recursive(eigvalsh, A, B)) ** 2).sum(axis=-1)
      return d2 if squared else np.sqrt(d2)
  
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 10 for calling a global function with example usage: distance_riemann(A, B, squared) and returns: unknown