code: def test_fit_and_compare_with_em(self, implementation):
      # Explicitly setting Random State to test that certain
      # model states will become "unused"
      sequences, lengths = self.get_from_one_beal(7, 100, 1984)
      model = vhmm.VariationalCategoricalHMM(
          4,
          n_iter=500,
          random_state=1984,
          init_params="e",
          implementation=implementation,
      )
      vi_uniform_startprob_and_transmat(model, lengths)
      model.fit(sequences, lengths)
  
      # The 1st hidden state will be "unused"
      assert model.transmat_posterior_[1, :] == pytest.approx(
          0.25, rel=1e-3
      )
      assert model.emissionprob_posterior_[1, :] == pytest.approx(
          0.3333, rel=1e-3
      )
  
      # An EM Model should behave the same behavior as a Variational Model,
      # When initialized with the normalized probabilities of the mode of the
      # Variational MOdel.
      em_hmm = hmm.CategoricalHMM(n_components=4, init_params="")
      em_hmm.startprob_ = model.startprob_
      em_hmm.transmat_ = model.transmat_
      em_hmm.emissionprob_ = model.emissionprob_
  
      compare_variational_and_em_models(
          model, em_hmm, sequences, lengths
      )
  
file_path: hmmlearn/lib/hmmlearn/tests/test_variational_categorical.py
imports: import numpy
  import pytest
  from sklearn.utils import check_random_state
  from hmmlearn import hmm, vhmm
  from .None import assert_log_likelihood_increasing, compare_variational_and_em_models, vi_uniform_startprob_and_transmat
label_desc: Use image node_id 8 for calling the TestVariationalCategorical obj's underlying member method code with example usage: obj.test_fit_and_compare_with_em(implementation) without return types