code: def test_EER(device):
      from speechbrain.utils.metric_stats import EER
  
      positive_scores = torch.tensor([0.1, 0.2, 0.3], device=device)
      negative_scores = torch.tensor([0.4, 0.5, 0.6], device=device)
      eer, threshold = EER(positive_scores, negative_scores)
      assert eer == 1.0
      assert threshold > 0.3 and threshold < 0.4
  
      positive_scores = torch.tensor([0.4, 0.5, 0.6], device=device)
      negative_scores = torch.tensor([0.3, 0.2, 0.1], device=device)
      eer, threshold = EER(positive_scores, negative_scores)
      assert eer == 0
      assert threshold > 0.3 and threshold < 0.4
  
      cos = torch.nn.CosineSimilarity(dim=1, eps=1e-6)
      input1 = torch.randn(1000, 64, device=device)
      input2 = torch.randn(1000, 64, device=device)
      positive_scores = cos(input1, input2)
  
      input1 = torch.randn(1000, 64, device=device)
      input2 = torch.randn(1000, 64, device=device)
      negative_scores = cos(input1, input2)
  
      eer, threshold = EER(positive_scores, negative_scores)
  
      correct = (positive_scores > threshold).nonzero(
          as_tuple=False
      ).size(0) + (negative_scores < threshold).nonzero(
          as_tuple=False
      ).size(
          0
      )
  
      assert correct > 900 and correct < 1100
  
file_path: speechbrain/tests/unittests/test_metrics.py
imports: import torch
  import torch.nn
  import math
label_desc: Use image node_id 4 for calling a global function with example usage: test_EER(device) without return types