code: def metastability(alpha, T, right_eigenvectors, square_map, pi):
      
  
      num_micro, num_eigen = right_eigenvectors.shape
  
      A, chi, mapping = calculate_fuzzy_chi(alpha, square_map,
                                            right_eigenvectors)
  
      # If current point is infeasible or leads to degenerate lumping.
      if (len(np.unique(mapping)) != right_eigenvectors.shape[1] or
              has_constraint_violation(A, right_eigenvectors)):
          return -1.0 * np.inf
  
      obj = 0.0
      # Calculate  metastabilty of the lumped model.  Eqn 4.20 in LAA.
      for i in range(num_eigen):
          obj += np.dot(T.dot(chi[:, i]), pi * chi[:, i]) / np.dot(chi[:, i], pi)
  
      return obj
docs: Return the metastability PCCA+ objective function.
  
      Parameters
      ----------
      alpha : ndarray
          Parameters of objective function (e.g. flattened A)
      T : csr sparse matrix
          Transition matrix
      right_eigenvectors : ndarray
          The right eigenvectors.
      square_map : ndarray
          Mapping from square indices (i,j) to flat indices (k).
      pi : ndarray
          Equilibrium Populations of transition matrix.
  
      Returns
      -------
      obj : float
          The objective function
  
      Notes
      -------
      metastability: try to make metastable fuzzy state decomposition.
      Defined in ref. [2].