code: def compute_masked_metrics(
      frame_pairs: Sequence[FramePredictionPair],
      all_target_lens: List[int],
      all_target_length_preds: List[List[int]],
      select_length_beam: int,
      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,
      non_invalid_frame_pairs: Optional[
          Sequence[FramePredictionPair]
      ] = None,
      extracted_frame_pairs: Optional[
          Sequence[FramePredictionPair]
      ] = None,
      print_length_metrics: bool = True,
      num_weights=None,
      current_model_parameter_size=None,
  ) -> MaskedSeq2SeqJointMetrics:
      all_metrics = 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, length_reports = compute_length_metrics(
          all_target_lens,
          all_target_length_preds,
          select_length_beam,
          log_per_label_metrics=print_length_metrics,
      )
      # Compute sizes of 32bit, 8bit, and 4bit versions of the model
      # in MB (hence the conversion factor), if the number of weights is provided.
      # Default to -1 if unavailable.
      size_32bit_model = -1
      size_8bit_model = -1
      size_4bit_model = -1
      if num_weights:
          size_32bit_model = 32 * num_weights / (BIT2BYTE_CONSTANT)
          size_8bit_model = 8 * num_weights / (BIT2BYTE_CONSTANT)
          size_4bit_model = 4 * num_weights / (BIT2BYTE_CONSTANT)
      if not current_model_parameter_size:
          current_model_parameter_size = -1
  
      return MaskedSeq2SeqJointMetrics(
          top_intent_accuracy=all_metrics.top_intent_accuracy,
          current_model_parameter_size=current_model_parameter_size,
          size_32bit_model=size_32bit_model,
          size_8bit_model=size_8bit_model,
          size_4bit_model=size_4bit_model,
          frame_accuracy=all_metrics.frame_accuracy,
          frame_accuracy_top_k=all_metrics.frame_accuracy_top_k,
          frame_accuracies_by_depth=all_metrics.frame_accuracies_by_depth,
          bracket_metrics=all_metrics.bracket_metrics,
          tree_metrics=all_metrics.tree_metrics,
          percent_invalid_trees=all_metrics.percent_invalid_trees,
          percent_trees_wrong_label=all_metrics.percent_trees_wrong_label,
          loss=all_metrics.loss,
          length_metrics=length_metrics,
          length_reports=length_reports,
          non_invalid_fa=compute_frame_accuracy(
              non_invalid_frame_pairs
          ),
          extracted_fa=compute_frame_accuracy(extracted_frame_pairs),
          print_length_metrics=print_length_metrics,
      )
  
file_path: pytext/pytext/metrics/mask_metrics.py
imports: from typing import Dict, List, NamedTuple, Optional, Sequence
  from pytext.metrics import ClassificationMetrics, compute_classification_metrics, LabelPrediction
  from pytext.metrics.intent_slot_metrics import compute_all_metrics, compute_frame_accuracy, FrameAccuraciesByDepth, FramePredictionPair, IntentSlotMetrics, Node
  from sklearn.metrics import accuracy_score
label_desc: Use image node_id 2 for calling a global function with example usage: compute_masked_metrics(frame_pairs, all_target_lens, all_target_length_preds, select_length_beam, top_intent_accuracy, frame_accuracy, frame_accuracies_by_depth, bracket_metrics, tree_metrics, overall_metrics, all_predicted_frames, calculated_loss, length_metrics, non_invalid_frame_pairs, extracted_frame_pairs, print_length_metrics, num_weights, current_model_parameter_size) and returns: MaskedSeq2SeqJointMetrics