code: def test_em(classes, params, measurements):
      """Test adapters matrix estimation.
  
      Call `fit` of input adapter/s, and compare all matrix parameters with
      `pykalman-bardo`'s matrix parameters returned from `em`. This test
      is useful for both KalmanFilterTransformerPK and
      KalmanFilterTransformerFP.
      """
      mask_measurements = np.ma.masked_invalid(np.copy(measurements))
  
      for _class in classes:
          adapter = _class(**params)
          adapter = adapter.fit(measurements)
  
          kf_pykalman = init_kf_pykalman(
              measurement_dim=measurements.shape[1], **params
          )
          kf_pykalman = kf_pykalman.em(X=mask_measurements)
  
          assert np.array_equal(
              adapter.F_, kf_pykalman.transition_matrices
          )
          assert np.array_equal(
              adapter.H_, kf_pykalman.observation_matrices
          )
          assert np.array_equal(
              adapter.Q_, kf_pykalman.transition_covariance
          )
          assert np.array_equal(
              adapter.R_, kf_pykalman.observation_covariance
          )
          assert np.array_equal(
              adapter.X0_, kf_pykalman.initial_state_mean
          )
          assert np.array_equal(
              adapter.P0_, kf_pykalman.initial_state_covariance
          )
  
          if hasattr(adapter, "transition_offsets_"):
              assert np.array_equal(
                  adapter.transition_offsets_,
                  kf_pykalman.transition_offsets,
              )
          if hasattr(adapter, "measurement_offsets_"):
              assert np.array_equal(
                  adapter.measurement_offsets_,
                  kf_pykalman.observation_offsets,
              )
  
file_path: sktime/sktime/transformations/series/tests/test_kalman_filter.py
imports: import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal
  from sktime.transformations.series.kalman_filter import KalmanFilterTransformerFP, KalmanFilterTransformerPK
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 7 for calling a global function with example usage: test_em(classes, params, measurements) without return types