code: def state_to_modelparams(self, state):
          
          basis = self.flat()
          data = state.data.todense().view(np.ndarray).flatten()
  
          # NB: assumes Hermitian state and basis!
          return np.real(np.dot(basis.conj(), data))
docs: Converts a QuTiP-represented state into a model parameter vector.
  
          :param qutip.Qobj state: State to be converted.
          :rtype: :class:`np.ndarray`
          :return: The representation of the given state in this basis,
              as a vector of real parameters.