def flatten_and_filter_evidence_to_fever(claim_id,
                                         flat_evidence,
                                         max_evidence):
  """Convert flattened, ranked evidence to fever format.

  This filters out gold examples not present in the retrieval
  scrape, and converts to the format expected by the fever scoring script.

  Args:
    claim_id: The claim_id
    flat_evidence: The flattened, ranked evidence predictions
    max_evidence: The maximum evidence to use

  Returns:
    Fever formatted evidence
  """
  candidate_evidence = [
      evidence for evidence in flat_evidence
      if evidence.metadata['tfidf_candidate']
  ]

  # Get the first document, then get the fever verification prediction.
  verify_pred = candidate_evidence[0][1]
  return {
      'id':
          claim_id,
      'predicted_label':
          constants.FEVER_CLASSES[verify_pred],
      'predicted_evidence': [[
          candidate.metadata['wikipedia_url'], candidate.metadata['sentence_id']
      ] for candidate in candidate_evidence[:max_evidence]]
  }
Convert flattened, ranked evidence to fever format.

  This filters out gold examples not present in the retrieval
  scrape, and converts to the format expected by the fever scoring script.

  Args:
    claim_id: The claim_id
    flat_evidence: The flattened, ranked evidence predictions
    max_evidence: The maximum evidence to use

  Returns:
    Fever formatted evidence
  
language/serene/callbacks.py