code: def _sym_mat_pow(
      A, power, rcond=1e-7, reduce_rank=False, return_s=False
  ):
      """Exponentiate Hermitian matrices with optional rank reduction."""
      assert power in (-1, 0.5, -0.5)  # only used internally
      s, u = np.linalg.eigh(A)  # eigenvalues in ascending order
      # Is it positive semi-defidite? If so, keep real
      limit = s[..., -1:] * rcond
      if not (s >= -limit).all():  # allow some tiny small negative ones
          raise ValueError("Matrix is not positive semi-definite")
      s[s <= limit] = np.inf if power < 0 else 0
      if reduce_rank:
          # These are ordered smallest to largest, so we set the first one
          # to inf -- then the 1. / s below will turn this to zero, as needed.
          s[..., 0] = np.inf
      if power in (-0.5, 0.5):
          np.sqrt(s, out=s)
      use_s = 1.0 / s if power < 0 else s
      out = np.matmul(
          u * use_s[..., np.newaxis, :], u.swapaxes(-2, -1).conj()
      )
      if return_s:
          out = (out, s)
      return out
  
file_path: mne-python/mne/utils/linalg.py
imports: import functools
  import numpy
  from scipy import linalg
  from scipy._lib._util import _asarray_validated
label_desc: Use image node_id 8 for calling a global function with example usage: _sym_mat_pow(A, power, rcond, reduce_rank, return_s) and returns: out