code: def compute_prf1_metrics(
      nodes_pairs: Sequence[NodesPredictionPair],
  ) -> Tuple[AllConfusions, PRF1Metrics]:
      """
      Computes precision/recall/F1 metrics given a list of predicted and expected sets of
      nodes.
  
      Args:
          nodes_pairs: List of predicted and expected node sets.
  
      Returns:
          A tuple, of which the first member contains the confusion information, and the
          second member contains the computed precision/recall/F1 metrics.
      """
      all_confusions = AllConfusions()
      for predicted_nodes, expected_nodes in nodes_pairs:
          all_confusions.confusions += _compare_nodes(
              predicted_nodes,
              expected_nodes,
              all_confusions.per_label_confusions,
          )
      return all_confusions, all_confusions.compute_metrics()
  
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 4 for calling a global function with example usage: compute_prf1_metrics(nodes_pairs) and returns: all_confusions,  all_confusions