code: def distance_kullback(A, B, squared=False):
      r"""Kullback-Leibler divergence between SPD/HPD matrices.
  
      The left Kullback-Leibler divergence between two SPD/HPD matrices
      :math:`\mathbf{A}` and :math:`\mathbf{B}` is [1]_:
  
      .. math::
          d(\mathbf{A},\mathbf{B}) =
          \frac{1}{2} \left( \text{tr}(\mathbf{B}^{-1}\mathbf{A}) - n
          + \log \left( \frac{\det(\mathbf{B})}{\det(\mathbf{A})}\right) \right)
  
      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 (...,)
          Left Kullback-Leibler divergence between A and B.
  
      See Also
      --------
      distance
  
      References
      ----------
      .. [1] `On information and sufficiency
          <https://www.jstor.org/stable/2236703>`_
          S. Kullback S, R. Leibler.
          The Annals of Mathematical Statistics, 1951, 22 (1), pp. 79-86
      """
      _check_inputs(A, B)
      n = A.shape[-1]
      tr = np.trace(
          _recursive(solve, B, A, assume_a="pos"), axis1=-2, axis2=-1
      )
      logdet = np.linalg.slogdet(B)[1] - np.linalg.slogdet(A)[1]
      d = 0.5 * (tr - n + logdet).real
      return d**2 if squared else d
  
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 5 for calling a global function with example usage: distance_kullback(A, B, squared) and returns: unknown