code: def squad_v2_f1(
      y_true: List[List[str]], y_predicted: List[str]
  ) -> float:
      """Calculates F-1 score between y_true and y_predicted
          F-1 score uses the best matching y_true answer
  
      The same as in SQuAD-v2.0
  
      Args:
          y_true: list of correct answers (correct answers are represented by list of strings)
          y_predicted: list of predicted answers
  
      Returns:
          F-1 score : float
      """
      f1_total = 0.0
      for ground_truth, prediction in zip(y_true, y_predicted):
          prediction_tokens = normalize_answer(prediction).split()
          f1s = []
          for gt in ground_truth:
              gt_tokens = normalize_answer(gt).split()
              if len(gt_tokens) == 0 or len(prediction_tokens) == 0:
                  f1s.append(float(gt_tokens == prediction_tokens))
                  continue
              common = Counter(prediction_tokens) & Counter(gt_tokens)
              num_same = sum(common.values())
              if num_same == 0:
                  f1s.append(0.0)
                  continue
              precision = 1.0 * num_same / len(prediction_tokens)
              recall = 1.0 * num_same / len(gt_tokens)
              f1 = (2 * precision * recall) / (precision + recall)
              f1s.append(f1)
          f1_total += max(f1s)
      return 100 * f1_total / len(y_true) if len(y_true) > 0 else 0
  
file_path: DeepPavlov/deeppavlov/metrics/squad_metrics.py
imports: import re
  import string
  from collections import Counter
  from typing import List
  from deeppavlov.core.common.metrics_registry import register_metric
label_desc: Use image node_id 3 for calling a global function with example usage: squad_v2_f1(y_true, y_predicted) and returns: unknown