code: def test_compute_intent_slot_metrics(self) -> None:
      # Test single pair
      self.assertMetricsAlmostEqual(
          compute_intent_slot_metrics(
              FRAME_PAIRS[1:2], tree_based=False
          ),
          IntentSlotMetrics(
              intent_metrics=PRF1Metrics(
                  per_label_scores={
                      "intent1": PRF1Scores(1, 0, 0, 1.0, 1.0, 1.0)
                  },
                  macro_scores=MacroPRF1Scores(1, 1.0, 1.0, 1.0),
                  micro_scores=PRF1Scores(1, 0, 0, 1.0, 1.0, 1.0),
              ),
              slot_metrics=PRF1Metrics(
                  per_label_scores={
                      "slot1": PRF1Scores(0, 0, 1, 0.0, 0.0, 0.0)
                  },
                  macro_scores=MacroPRF1Scores(1, 0.0, 0.0, 0.0),
                  micro_scores=PRF1Scores(0, 0, 1, 0.0, 0.0, 0.0),
              ),
              overall_metrics=PRF1Scores(1, 0, 1, 1.0, 0.5, 2.0 / 3),
          ),
      )
      self.assertMetricsAlmostEqual(
          compute_intent_slot_metrics(
              FRAME_PAIRS[1:2], tree_based=True
          ),
          IntentSlotMetrics(
              intent_metrics=PRF1Metrics(
                  per_label_scores={
                      "intent1": PRF1Scores(0, 1, 1, 0.0, 0.0, 0.0)
                  },
                  macro_scores=MacroPRF1Scores(1, 0.0, 0.0, 0.0),
                  micro_scores=PRF1Scores(0, 1, 1, 0.0, 0.0, 0.0),
              ),
              slot_metrics=PRF1Metrics(
                  per_label_scores={
                      "slot1": PRF1Scores(0, 0, 1, 0.0, 0.0, 0.0)
                  },
                  macro_scores=MacroPRF1Scores(1, 0.0, 0.0, 0.0),
                  micro_scores=PRF1Scores(0, 0, 1, 0.0, 0.0, 0.0),
              ),
              overall_metrics=PRF1Scores(0, 1, 2, 0.0, 0.0, 0.0),
          ),
      )
  
      # Test multiple pairs consisting of the 8th through the 11th examples
      self.assertMetricsAlmostEqual(
          compute_intent_slot_metrics(
              FRAME_PAIRS[7:11], tree_based=False
          ),
          IntentSlotMetrics(
              intent_metrics=PRF1Metrics(
                  per_label_scores={
                      # intent1: TP = 4, FP = 0, FN = 0
                      "intent1": PRF1Scores(4, 0, 0, 1.0, 1.0, 1.0),
                      # intent2: TP = 1, FP = 2, FN = 1
                      "intent2": PRF1Scores(1, 2, 1, 1.0 / 3, 0.5, 0.4),
                  },
                  macro_scores=MacroPRF1Scores(2, 2.0 / 3, 0.75, 0.7),
                  # all intents: TP = 5, FP = 2, FN = 1
                  micro_scores=PRF1Scores(
                      5, 2, 1, 5.0 / 7, 5.0 / 6, 10.0 / 13
                  ),
              ),
              slot_metrics=PRF1Metrics(
                  per_label_scores={
                      # slot1: TP = 3, FP = 1, FN = 1
                      "slot1": PRF1Scores(3, 1, 1, 0.75, 0.75, 0.75),
                      # slot2: TP = 2, FP = 2, FN = 0
                      "slot2": PRF1Scores(2, 2, 0, 0.5, 1.0, 4.0 / 6),
                      # slot3: TP = 1, FP = 1, FN = 0
                      "slot3": PRF1Scores(1, 1, 0, 0.5, 1.0, 2.0 / 3),
                      # slot4: TP = 0, FP = 1, FN = 1
                      "slot4": PRF1Scores(0, 1, 1, 0.0, 0.0, 0.0),
                  },
                  macro_scores=MacroPRF1Scores(
                      4, 0.4375, 0.6875, 25.0 / 48
                  ),
                  # all slots: TP = 6, FP = 5, FN = 2
                  micro_scores=PRF1Scores(
                      6, 5, 2, 6.0 / 11, 6.0 / 8, 12.0 / 19
                  ),
              ),
              # overall: TP = 11, FP = 7, FN = 3
              overall_metrics=PRF1Scores(
                  11, 7, 3, 11.0 / 18, 11.0 / 14, 22.0 / 32
              ),
          ),
      )
  
      self.assertMetricsAlmostEqual(
          compute_intent_slot_metrics(
              FRAME_PAIRS[7:11], tree_based=True
          ),
          IntentSlotMetrics(
              intent_metrics=PRF1Metrics(
                  per_label_scores={
                      # intent1: TP = 1, FP = 3, FN = 3
                      "intent1": PRF1Scores(1, 3, 3, 0.25, 0.25, 0.25),
                      # intent2: TP = 1, FP = 2, FN = 1
                      "intent2": PRF1Scores(1, 2, 1, 1.0 / 3, 0.5, 0.4),
                  },
                  macro_scores=MacroPRF1Scores(
                      2, 7.0 / 24, 0.375, 0.325
                  ),
                  # all intents: TP = 2, FP = 5, FN = 4
                  micro_scores=PRF1Scores(
                      2, 5, 4, 2.0 / 7, 2.0 / 6, 4.0 / 13
                  ),
              ),
              slot_metrics=PRF1Metrics(
                  per_label_scores={
                      # slot1: TP = 2, FP = 2, FN = 2
                      "slot1": PRF1Scores(2, 2, 2, 0.5, 0.5, 0.5),
                      # slot2: TP = 2, FP = 2, FN = 0
                      "slot2": PRF1Scores(2, 2, 0, 0.5, 1.0, 4.0 / 6),
                      # slot3: TP = 1, FP = 1, FN = 0
                      "slot3": PRF1Scores(1, 1, 0, 0.5, 1.0, 2.0 / 3),
                      # slot4: TP = 0, FP = 1, FN = 1
                      "slot4": PRF1Scores(0, 1, 1, 0.0, 0.0, 0.0),
                  },
                  macro_scores=MacroPRF1Scores(
                      4, 0.375, 0.625, 11.0 / 24
                  ),
                  # all slots: TP = 5, FP = 6, FN = 3
                  micro_scores=PRF1Scores(
                      5, 6, 3, 5.0 / 11, 5.0 / 8, 10.0 / 19
                  ),
              ),
              # overall: TP = 7, FP = 11, FN = 7
              overall_metrics=PRF1Scores(
                  7, 11, 7, 7.0 / 18, 7.0 / 14, 14.0 / 32
              ),
          ),
      )
  
file_path: pytext/pytext/metrics/tests/intent_slot_metrics_test.py
imports: from typing import Any, Dict, List
  from pytext.data.data_structures.annotation import INVALID_TREE_INTENT
  from pytext.metrics import Confusions, MacroPRF1Scores
  from pytext.metrics.intent_slot_metrics import compare_frames, compute_all_metrics, compute_frame_accuracies_by_depth, compute_frame_accuracy, compute_intent_slot_metrics, compute_percent_invalid_trees, compute_percent_trees_wrong_label, compute_top_intent_accuracy, FrameAccuracy, FramePredictionPair, IntentSlotConfusions, IntentSlotMetrics, Node, PRF1Metrics, PRF1Scores, Span
  from pytext.metrics.tests.metrics_test_base import MetricsTestBase
label_desc: Use image node_id 3 for calling the MetricsTest obj's underlying member method code with example usage: obj.test_compute_intent_slot_metrics() without return types