code: def compute_all_metrics(
      frame_pairs: Sequence[FramePredictionPair],
      top_intent_accuracy: bool = True,
      frame_accuracy: bool = True,
      frame_accuracies_by_depth: bool = True,
      bracket_metrics: bool = True,
      tree_metrics: bool = True,
      overall_metrics: bool = False,
      all_predicted_frames: List[List[Node]] = None,
      calculated_loss: float = None,
      length_metrics: Dict = None,
  ) -> AllMetrics:
      """
      Given a list of predicted and gold intent frames, computes intent-slot related
      metrics.
  
      Args:
          frame_pairs: List of predicted and gold intent frames.
          top_intent_accuracy: Whether to compute top intent accuracy or not. Defaults to
              True.
          frame_accuracy: Whether to compute frame accuracy or not. Defaults to True.
          frame_accuracies_by_depth: Whether to compute frame accuracies by depth or not.
              Defaults to True.
          bracket_metrics: Whether to compute bracket metrics or not. Defaults to True.
          tree_metrics: Whether to compute tree metrics or not. Defaults to True.
          overall_metrics: If `bracket_metrics` or `tree_metrics` is true, decides whether
              to compute overall (merging intents and slots) metrics for them. Defaults to
              False.
  
      Returns:
          AllMetrics which contains intent-slot related metrics.
      """
      frame_accuracy_top_k = 0
      if all_predicted_frames:
          frame_accuracy_top_k = compute_frame_accuracy_top_k(
              frame_pairs, all_predicted_frames
          )
  
      top_intent = (
          compute_top_intent_accuracy(frame_pairs)
          if top_intent_accuracy
          else None
      )
      accuracy = (
          compute_frame_accuracy(frame_pairs)
          if frame_accuracy
          else None
      )
      accuracies = (
          compute_frame_accuracies_by_depth(frame_pairs)
          if frame_accuracies_by_depth
          else None
      )
      bracket = (
          compute_intent_slot_metrics(
              frame_pairs,
              tree_based=False,
              overall_metrics=overall_metrics,
          )
          if bracket_metrics
          else None
      )
      tree = (
          compute_intent_slot_metrics(
              frame_pairs,
              tree_based=True,
              overall_metrics=overall_metrics,
          )
          if tree_metrics
          else None
      )
      invalid_trees = compute_percent_invalid_trees(frame_pairs)
      trees_wrong_label = compute_percent_trees_wrong_label(frame_pairs)
  
      return AllMetrics(
          top_intent,
          accuracy,
          frame_accuracy_top_k,
          accuracies,
          bracket,
          tree,
          invalid_trees,
          trees_wrong_label,
          calculated_loss,
      )
  
imports: from collections import Counter, defaultdict
  from copy import deepcopy
  from typing import AbstractSet, Any, Callable, Counter, Dict, List, NamedTuple, Optional, Sequence, Tuple
  from pytext.data.data_structures.annotation import INVALID_TREE_INTENT
  from pytext.data.data_structures.node import Node, Span
  from .None import AllConfusions, Confusions, PerLabelConfusions, PRF1Metrics, PRF1Scores, safe_division
label_desc: Use image node_id 15 for calling a global function with example usage: compute_all_metrics(frame_pairs, top_intent_accuracy, frame_accuracy, frame_accuracies_by_depth, bracket_metrics, tree_metrics, overall_metrics, all_predicted_frames, calculated_loss, length_metrics) and returns: AllMetrics