code: def test_categorized_classification_stats():
      import pytest
      from speechbrain.utils.metric_stats import ClassificationStats
  
      stats = ClassificationStats()
      stats.append(
          ids=["1", "2"],
          predictions=["B", "A"],
          targets=["B", "A"],
          categories=["C1", "C2"],
      )
      stats.append(
          ids=["3", "4"],
          predictions=["A", "B"],
          targets=["B", "C"],
          categories=["C2", "C1"],
      )
      stats.append(
          ids=["5", "6"],
          predictions=["A", "C"],
          targets=["B", "C"],
          categories=["C2", "C1"],
      )
  
      summary = stats.summarize()
      assert pytest.approx(summary["accuracy"], 0.01) == 0.5
      classwise_accuracy = summary["classwise_accuracy"]
      assert pytest.approx(classwise_accuracy["C1", "B"]) == 1.0
      assert pytest.approx(classwise_accuracy["C1", "C"]) == 0.5
      assert pytest.approx(classwise_accuracy["C2", "A"]) == 1.0
      assert pytest.approx(classwise_accuracy["C2", "B"]) == 0.0
  
file_path: speechbrain/tests/unittests/test_metrics.py
imports: import torch
  import torch.nn
  import math
label_desc: Use image node_id 7 for calling a global function with example usage: test_categorized_classification_stats() without return types