code: def compute_f1(a_gold, a_pred):
      """
      Compute the token-level f1 scores in which the common tokens are considered
      as True Positives. Precision and recall are percentages of the number of
      common tokens in the prediction and groud truth, respectively.
      """
      gold_toks = get_tokens(a_gold)
      pred_toks = get_tokens(a_pred)
      common = collections.Counter(gold_toks) & collections.Counter(
          pred_toks
      )
      num_same = sum(common.values())
      if len(gold_toks) == 0 or len(pred_toks) == 0:
          # If either is no-answer, then F1 is 1 if they agree, 0 otherwise
          return int(gold_toks == pred_toks)
      if num_same == 0:
          return 0
      precision = 1.0 * num_same / len(pred_toks)
      recall = 1.0 * num_same / len(gold_toks)
      f1 = (2 * precision * recall) / (precision + recall)
      return f1
  
file_path: gluon-nlp/scripts/question_answering/eval_utils.py
imports: import collections
  import json
  import copy
  import re
  import string
label_desc: Use image node_id 5 for calling a global function with example usage: compute_f1(a_gold, a_pred) and returns: f1, int, int