code: def sqrtm_psd(A, est_error=True, check_finite=True):
      
      w, v = eigh(A, check_finite=check_finite)
      mask = w <= 0
      w[mask] = 0
      np.sqrt(w, out=w)
      A_sqrt = (v * w).dot(v.conj().T)
  
      if est_error:
          return A_sqrt, np.linalg.norm(np.dot(A_sqrt, A_sqrt) - A, 'fro')
      else:
          return A_sqrt
docs: Returns the matrix square root of a positive semidefinite matrix,
      truncating negative eigenvalues.