code: def predict(self, obs, pstates, next_pstate=None):
          
          assert len(obs) == len(pstates)
          pstates_idx = np.array([self.e[ei] for ei in pstates])
          next_pstate_idx = self.e[next_pstate]
  
          if len(obs) == 0:
              # No history, use the starting probas
              next_hstate_prob = self.startprob[next_pstate_idx]
          else:
              # With a history, determine the hidden state posteriors using
              # the last posteriors and transition matrix
              framelogprob = self._compute_log_likelihood(obs, pstates_idx)
              _, fwdlattice = self._do_forward_pass(framelogprob, pstates_idx)
  
              next_hstate_prob = np.zeros(self.n_hidden_states)
  
              alpha_n = fwdlattice[-1]
              vmax = alpha_n.max(axis=0)
              alpha_n = np.exp(alpha_n - vmax)
              alpha_n = alpha_n / alpha_n.sum()
  
              trans = self.transmat[pstates_idx[-1], next_pstate_idx]
  
              for i in range(self.n_hidden_states):
                  next_hstate_prob[i] = np.sum([alpha_n[j] * trans[j, i] for j in range(self.n_hidden_states)])
  
          assert next_hstate_prob.sum() - 1 < TOLERANCE
  
          # Make the prediction
          prediction = np.array(
              [self.expected_value(feature, pstate=next_pstate, hstate_prob=next_hstate_prob) for feature in
               self.emission_name])
  
          # next_hstate = np.argmax(next_hstate_prob)
          # prediction = np.array(
          #     [self.expected_value(feature, pstate=next_pstate, hstate=next_hstate) for feature in
          #      self.emission_name])
  
          return prediction
docs: Predict the next observation