def compute_f1(prediction, gold_answers):
  """Computes F1 score for a single prediction and a list of gold answers.

  See 'compute_f1_single' for details. Expects all input strings to be unicode.

  Args:
    prediction: predicted string.
    gold_answers: a list of ground truth strings.

  Returns:
    Maximum of the token-wise F1 score between the prediction and each gold
    answer.
  """
  if not gold_answers:
    return 0.0
  else:
    f1_scores = []
    prediction = normalize_answer(prediction)
    for answer in gold_answers:
      f1_scores.append(compute_f1_single(prediction, normalize_answer(answer)))

    return max(f1_scores)
Computes F1 score for a single prediction and a list of gold answers.

  See 'compute_f1_single' for details. Expects all input strings to be unicode.

  Args:
    prediction: predicted string.
    gold_answers: a list of ground truth strings.

  Returns:
    Maximum of the token-wise F1 score between the prediction and each gold
    answer.
  
language/search_agents/muzero/utils.py