code: def test_mahalanobis_torch_backend_ts(tmp_path):
      """Test Mahalanobis detector backend is torch-scriptable and savable."""
      mahalanobis_torch = MahalanobisTorch()
      x = torch.randn((3, 10)) * torch.tensor([[1], [1], [100]])
      x_ref = torch.randn((1024, 10))
      mahalanobis_torch.fit(x_ref)
      mahalanobis_torch.infer_threshold(x_ref, 0.1)
      pred_1 = mahalanobis_torch(x)
  
      mahalanobis_torch = torch.jit.script(mahalanobis_torch)
      pred_2 = mahalanobis_torch(x)
      assert torch.all(pred_1 == pred_2)
  
      mahalanobis_torch.save(tmp_path / "mahalanobis_torch.pt")
      mahalanobis_torch = torch.load(tmp_path / "mahalanobis_torch.pt")
      pred_2 = mahalanobis_torch(x)
      assert torch.all(pred_1 == pred_2)
  
imports: import pytest
  import torch
  import numpy
  from alibi_detect.od.pytorch.mahalanobis import MahalanobisTorch
  from alibi_detect.exceptions import NotFittedError, ThresholdNotInferredError
label_desc: Use image node_id 2 for calling a global function with example usage: test_mahalanobis_torch_backend_ts(tmp_path) without return types