def _record_fever_metrics(self,
                            *,
                            ranked_evidence,
                            epoch,
                            n_evidence,
                            scrape_type,
                            logs = None):
    """Compute and record fever metrics.

    Args:
      ranked_evidence: Evidence grouped and sorted by claim_id
      epoch: Current epoch
      n_evidence: Number of evidence, if None default to self._max_evidence
      scrape_type: The source scrape type to record in metrics
      logs: logs dictionary to read/write
    """
    if len(ranked_evidence) != len(self._verifiable_dev_lookup):
      logging.warning(
          'Mismatched lengths for gold/pred claims: %s vs %s',
          len(ranked_evidence), len(self._verifiable_dev_lookup))
    if self._debug:
      self._debug_metrics(logs)
      return
    # Compute formatted predictions and gold for fever score function
    formatted_predictions = []
    actual = []
    max_evidence = n_evidence if n_evidence is not None else self._max_evidence
    for claim_id, claim in self._verifiable_dev_lookup.items():
      if claim_id in ranked_evidence:
        prediction = flatten_and_filter_evidence_to_fever(
            claim_id, ranked_evidence[claim_id], max_evidence)
        formatted_predictions.append(prediction)
        actual.append({'evidence': claim['evidence'], 'label': claim['label']})
      else:
        logging.warning(
            'Missing prediction for claim_id=%s type=%s',
            claim_id, type(claim_id))

    # Compute fever metrics
    strict_score, accuracy_score, precision, recall, f1 = fever_score(
        formatted_predictions, actual)
    metrics = {
        f'val_fever_strict_score_{scrape_type}_{max_evidence}':
            strict_score,
        f'val_fever_accuracy_score_{scrape_type}_{max_evidence}':
            accuracy_score,
        f'val_fever_precision_{scrape_type}_{max_evidence}':
            precision,
        f'val_fever_recall_{scrape_type}_{max_evidence}':
            recall,
        f'val_fever_f1_{scrape_type}_{max_evidence}':
            f1
    }
    for name, value in metrics.items():
      logging.info(
          'epoch %s: %s=%s',
          epoch, name, value)
      if logs is not None:
        logs[name] = value  # pytype: disable=container-type-mismatch  # always-use-return-annotations
Compute and record fever metrics.

    Args:
      ranked_evidence: Evidence grouped and sorted by claim_id
      epoch: Current epoch
      n_evidence: Number of evidence, if None default to self._max_evidence
      scrape_type: The source scrape type to record in metrics
      logs: logs dictionary to read/write
    
language/serene/callbacks.py