code: def compute_frame_accuracy_top_k(
      frame_pairs: List[FramePredictionPair],
      all_frames: List[List[Node]],
  ) -> float:
      num_samples = len(frame_pairs)
      num_correct = 0
      for i, top_k_predicted_frames in enumerate(all_frames):
          _, expected_frame = frame_pairs[i]
          for predicted_frame in top_k_predicted_frames:
              if predicted_frame == expected_frame:
                  num_correct += 1
                  break
      return safe_division(num_correct, num_samples)
  
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 8 for calling a global function with example usage: compute_frame_accuracy_top_k(frame_pairs, all_frames) and returns: safe_division