code: def calc_f1_msmarco(pred: str, gold_items: List[str]) -> float:
      """
      Calculate F1 overlap between prediction sentence and gold labels.
  
      :param pred:
          prediction string
      :param gold_items:
          list of gold items
  
      :return f1_overlap:
      """
      try:
          assert nltk is not None
          pred_items = nltk.word_tokenize(pred)
      except IndexError:
          # malformed prediction; return 0
          return 0
      common = Counter(gold_items) & Counter(pred_items)
      num_same = sum(common.values())
      if num_same == 0:
          return 0
      precision = 1.0 * num_same / len(pred_items)
      recall = 1.0 * num_same / len(gold_items)
      f1 = (2 * precision * recall) / (precision + recall)
      return f1
  
file_path: ParlAI/projects/seeker/utils.py
imports: from collections import Counter
  from enum import Enum
  import torch
  from typing import Callable, List, Tuple
  from parlai.core.torch_agent import Batch
  from parlai.tasks.wizard_of_wikipedia.agents import TOKEN_KNOWLEDGE, TOKEN_END_KNOWLEDGE
  import parlai.utils.logging
label_desc: Use image node_id 5 for calling a global function with example usage: calc_f1_msmarco(pred, gold_items) and returns: f1, int, int