code: def eigenvalues(T, k=None, reversible=False, mu=None):
      r
      if reversible:
          try:
              evals = eigenvalues_rev(T, k=k, mu=mu)
          except:
              evals = eigvals(T).real  # use fallback code but cast to real
      else:
          evals = eigvals(T)  # nonreversible
  
      """Sort by decreasing absolute value"""
      ind = np.argsort(np.abs(evals))[::-1]
      evals = evals[ind]
  
      if isinstance(k, (list, set, tuple)):
          try:
              return [evals[n] for n in k]
          except IndexError:
              raise ValueError("given indices do not exist: ", k)
      elif k is not None:
          return evals[: k]
      else:
          return evals
docs: r"""Compute eigenvalues of given transition matrix.
  
      Parameters
      ----------
      T : (d, d) ndarray
          Transition matrix (stochastic matrix)
      k : int or tuple of ints, optional
          Compute the first k eigenvalues of T
      reversible : bool, optional
          Indicate that transition matrix is reversible
      mu : (d,) ndarray, optional
          Stationary distribution of T
  
      Returns
      -------
      eig : (n,) ndarray,
          The eigenvalues of T ordered with decreasing absolute value.
          If k is None then n=d, if k is int then n=k otherwise
          n is the length of the given tuple of eigenvalue indices.
  
      Notes
      -----
      Eigenvalues are computed using the numpy.linalg interface
      for the corresponding LAPACK routines.
  
      If reversible=True the the eigenvalues of the similar symmetric
      matrix `\sqrt(\mu_i / \mu_j) p_{ij}` will be computed.
  
      The precomputed stationary distribution will only be used if
      reversible=True.