code: def test_gmm_sklearn_backend_fit_errors():
      """Test gmm detector sklearn backend fit errors.
  
      Tests the correct errors are raised when using the GMMSklearn backend detector.
      """
      gmm_sklearn = GMMSklearn(n_components=2)
      assert not gmm_sklearn.fitted
  
      # Test that the backend raises an error if it is not fitted before
      # calling forward method.
      x = np.random.randn(1, 10)
      with pytest.raises(NotFittedError) as err:
          gmm_sklearn(x)
      assert str(err.value) == "GMMSklearn has not been fit!"
  
      # Test that the backend raises an error if it is not fitted before
      # predicting.
      with pytest.raises(NotFittedError) as err:
          gmm_sklearn.predict(x)
      assert str(err.value) == "GMMSklearn has not been fit!"
  
      # Test the backend updates _fitted flag on fit.
      x_ref = np.random.randn(1024, 10)
      gmm_sklearn.fit(x_ref)
      assert gmm_sklearn.fitted
  
      # Test that the backend raises an if the forward method is called without the
      # threshold being inferred.
      with pytest.raises(ThresholdNotInferredError) as err:
          gmm_sklearn(x)
      assert (
          str(err.value)
          == "GMMSklearn has no threshold set, call `infer_threshold` to fit one!"
      )
  
      # Test that the backend can call predict without the threshold being inferred.
      assert gmm_sklearn.predict(x)
  
imports: import pytest
  import numpy
  from alibi_detect.od.sklearn.gmm import GMMSklearn
  from alibi_detect.exceptions import NotFittedError, ThresholdNotInferredError
label_desc: Use image node_id 2 for calling a global function with example usage: test_gmm_sklearn_backend_fit_errors() without return types