code: def test_gmm_torch_backend_ts(tmp_path):
      """Test GMM detector backend is torch-scriptable and savable."""
      gmm_torch = GMMTorch(n_components=2)
      x = torch.randn((3, 10)) * torch.tensor([[1], [1], [100]])
      x_ref = torch.randn((1024, 10))
      gmm_torch.fit(x_ref)
      gmm_torch.infer_threshold(x_ref, 0.1)
      pred_1 = gmm_torch(x)
  
      gmm_torch = torch.jit.script(gmm_torch)
      pred_2 = gmm_torch(x)
      assert torch.all(pred_1 == pred_2)
  
      gmm_torch.save(tmp_path / "gmm_torch.pt")
      gmm_torch = torch.load(tmp_path / "gmm_torch.pt")
      pred_2 = gmm_torch(x)
      assert torch.all(pred_1 == pred_2)
  
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 2 for calling a global function with example usage: test_gmm_torch_backend_ts(tmp_path) without return types