code: def test_gmm_pytorch_scoring():
      """Test GMM detector pytorch scoring method.
  
      Tests the scoring method of the GMMTorch pytorch backend detector.
      """
      gmm_torch = GMMTorch(n_components=1)
      mean = [8, 8]
      cov = [[2.0, 0.0], [0.0, 1.0]]
      x_ref = torch.tensor(
          np.random.multivariate_normal(mean, cov, 1000)
      )
      gmm_torch.fit(x_ref)
  
      x_1 = torch.tensor(np.array([[8.0, 8.0]]))
      scores_1 = gmm_torch.score(x_1)
  
      x_2 = torch.tensor(np.random.multivariate_normal(mean, cov, 1))
      scores_2 = gmm_torch.score(x_2)
  
      x_3 = torch.tensor(np.array([[-10.0, 10.0]]))
      scores_3 = gmm_torch.score(x_3)
  
      # test correct ordering of scores given outlyingness of data
      assert scores_1 < scores_2 < scores_3
  
      # test that detector correctly detects true outlier
      gmm_torch.infer_threshold(x_ref, 0.01)
      x = torch.cat((x_1, x_2, x_3))
      outputs = gmm_torch.predict(x)
      assert torch.all(
          outputs.is_outlier == torch.tensor([False, False, True])
      )
      assert torch.all(
          gmm_torch(x) == torch.tensor([False, False, True])
      )
  
      # test that 0.01 of the in distribution data is flagged as outliers
      x = torch.tensor(np.random.multivariate_normal(mean, cov, 1000))
      outputs = gmm_torch.predict(x)
      assert (outputs.is_outlier.sum() / 1000) - 0.01 < 0.01
  
file_path: alibi-detect/alibi_detect/od/tests/test__gmm/test__gmm_pytorch_backend.py
imports: import pytest
  import numpy
  import torch
  from alibi_detect.od.pytorch.gmm import GMMTorch
  from alibi_detect.exceptions import NotFittedError, ThresholdNotInferredError
label_desc: Use image node_id 1 for calling a global function with example usage: test_gmm_pytorch_scoring() without return types