code: def test_pval_normalizer():
      """Test the PValNormalizer
  
      - Test the PValNormalizer correctly normalizes data passed to it
      - Test the PValNormalizer throws the correct errors if not fit
      """
      normalizer = ensemble.PValNormalizer()
      x = torch.randn(3, 10)
      x_ref = torch.randn(64, 10)
      # unfit normalizer raises exception
      with pytest.raises(NotFittedError) as err:
          normalizer(x)
      assert err.value.args[0] == "PValNormalizer has not been fit!"
  
      normalizer.fit(x_ref)
      x_norm = normalizer(x)
  
      # compute the p-values explicitly and compare to the normalizer
      # output.
      assert torch.all(0 < x_norm)
      assert torch.all(x_norm < 1)
      for i in range(3):
          for j in range(10):
              comp_pval = (
                  (x_ref[:, j] > x[i][j]).to(torch.float32)
              ).sum() + 1
              comp_pval /= x_ref.shape[0] + 1
              normalizer_pval = x_norm[i][j].to(torch.float32)
              assert torch.isclose(
                  1 - comp_pval, normalizer_pval, atol=1e-4
              )
  
      # Test the scriptability of the normalizer
      normalizer = torch.jit.script(normalizer)
      x_norm_2 = normalizer(x)
      assert torch.all(x_norm_2 == x_norm)
  
file_path: alibi-detect/alibi_detect/od/tests/test_ensemble.py
imports: import pytest
  import torch
  from alibi_detect.od.pytorch import ensemble
  from alibi_detect.exceptions import NotFittedError
label_desc: Use image node_id 1 for calling a global function with example usage: test_pval_normalizer() without return types