code: def test_binary_metrics(device):
      from speechbrain.utils.metric_stats import BinaryMetricStats
  
      binary_stats = BinaryMetricStats()
      binary_stats.append(
          ids=["utt1", "utt2", "utt3", "utt4", "utt5", "utt6"],
          scores=torch.tensor(
              [0.1, 0.4, 0.8, 0.2, 0.3, 0.6], device=device
          ),
          labels=torch.tensor([1, 0, 1, 0, 1, 0], device=device),
      )
      summary = binary_stats.summarize(threshold=0.5)
      assert summary["TP"] == 1
      assert summary["TN"] == 2
      assert summary["FP"] == 1
      assert summary["FN"] == 2
  
      summary = binary_stats.summarize(threshold=None)
      assert summary["threshold"] >= 0.3 and summary["threshold"] < 0.4
  
      summary = binary_stats.summarize(threshold=None, max_samples=1)
      assert summary["threshold"] >= 0.1 and summary["threshold"] < 0.2
  
file_path: speechbrain/tests/unittests/test_metrics.py
imports: import torch
  import torch.nn
  import math
label_desc: Use image node_id 3 for calling a global function with example usage: test_binary_metrics(device) without return types