code: def eigenvalues_rev(T, k, ncv=None, mu=None):
      r
  
      """compute stationary distribution if not given"""
      if mu is None:
          mu = stationary_distribution(T)
      if np.any(mu <= 0):
          raise ValueError('Cannot symmetrize transition matrix')
      """ symmetrize T """
      smu = np.sqrt(mu)
      D = diags(smu, 0)
      Dinv = diags(1.0/smu, 0)
      S = (D.dot(T)).dot(Dinv)
      """Compute eigenvalues using a solver for symmetric/hermititan eigenproblems"""
      evals = scipy.sparse.linalg.eigsh(S, k=k, ncv=ncv, which='LM', return_eigenvectors=False)
      return evals
docs: r"""Compute the eigenvalues of a reversible, sparse transition matrix.
  
      Parameters
      ----------
      T : (M, M) scipy.sparse matrix
          Transition matrix
      k : int
          Number of eigenvalues to compute.
      ncv : int, optional
          The number of Lanczos vectors generated, `ncv` must be greater than k;
          it is recommended that ncv > 2*k
      mu : (M,) ndarray, optional
          Stationary distribution of T
  
      Returns
      -------
      v : (k,) ndarray
          Eigenvalues of T
  
      Raises
      ------
      ValueError
          If stationary distribution is nonpositive.
  
      Notes
      -----
      The first k eigenvalues of largest magnitude are computed.