code: def _solve_msm_eigensystem(transmat, k):
      
      u, lv, rv = scipy.linalg.eig(transmat, left=True, right=True)
      order = np.argsort(-np.real(u))
      u = np.real_if_close(u[order[:k]])
      lv = np.real_if_close(lv[:, order[:k]])
      rv = np.real_if_close(rv[:, order[:k]])
      return _normalize_eigensystem(u, lv, rv)
docs: Find the dominant eigenpairs of an MSM transition matrix
  
      Parameters
      ----------
      transmat : np.ndarray, shape=(n_states, n_states)
          The transition matrix
      k : int
          The number of eigenpairs to find.
  
      Notes
      -----
      Normalize the left (:math:`\phi`) and right (:math:``\psi``) eigenfunctions
      according to the following criteria.
        * The first left eigenvector, \phi_1, _is_ the stationary
          distribution, and thus should be normalized to sum to 1.
        * The left-right eigenpairs should be biorthonormal:
          <\phi_i, \psi_j> = \delta_{ij}
        * The left eigenvectors should satisfy
          <\phi_i, \phi_i>_{\mu^{-1}} = 1
        * The right eigenvectors should satisfy <\psi_i, \psi_i>_{\mu} = 1
  
      Returns
      -------
      eigvals : np.ndarray, shape=(k,)
          The largest `k` eigenvalues
      lv : np.ndarray, shape=(n_states, k)
          The normalized left eigenvectors (:math:`\phi`) of ``transmat``
      rv :  np.ndarray, shape=(n_states, k)
          The normalized right eigenvectors (:math:`\psi`) of ``transmat``