code: def test_gmmhmm_multi_sequence_fit_invariant_to_sequence_ordering(
      covariance_type, implementation, init_params="mcw", verbose=False
  ):
      """
      Sanity check GMM-HMM fit behaviour when run on multiple sequences
      aka multiple frames.
  
      Training data consumed during GMM-HMM fit is packed into a single
      array X containing one or more sequences. In the case where
      there are two or more input sequences, the ordering that the
      sequences are packed into X should not influence the results
      of the fit. Major differences in convergence during EM
      iterations by merely permuting sequence order in the input
      indicates a likely defect in the fit implementation.
  
      Note: the ordering of samples inside a given sequence
      is very meaningful, permuting the order of samples would
      destroy the the state transition structure in the input data.
  
      See issue 410 on github:
      https://github.com/hmmlearn/hmmlearn/issues/410
      """
      sequence_data = EXAMPLE_SEQUENCES_ISSUE_410_PRUNED
  
      scores = []
      for p in make_permutations(sequence_data):
          sequences = sequence_data[p]
          X = np.concatenate(sequences)
          lengths = [len(seq) for seq in sequences]
  
          model = hmm.GMMHMM(
              n_components=2,
              n_mix=2,
              n_iter=100,
              covariance_type=covariance_type,
              verbose=verbose,
              init_params=init_params,
              random_state=1234,
              implementation=implementation,
          )
  
          # don't use random parameters for testing
          init = 1.0 / model.n_components
          model.startprob_ = np.full(model.n_components, init)
          model.transmat_ = np.full(
              (model.n_components, model.n_components), init
          )
  
          model.monitor_ = StrictMonitor(
              model.monitor_.tol,
              model.monitor_.n_iter,
              model.monitor_.verbose,
          )
  
          model.fit(X, lengths)
  
          assert model.monitor_.converged
          scores.append(model.score(X, lengths))
  
      # Choice of rtol value is ad-hoc, no theoretical motivation.
      assert_allclose(scores, np.mean(scores), rtol=5e-03)
  
file_path: hmmlearn/lib/hmmlearn/tests/test_gmm_hmm_multisequence.py
imports: import itertools
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  from hmmlearn import hmm
  from hmmlearn.base import ConvergenceMonitor
label_desc: Use image node_id 2 for calling a global function with example usage: test_gmmhmm_multi_sequence_fit_invariant_to_sequence_ordering(covariance_type, implementation, init_params, verbose) without return types