def print_predictions(targets, predictions):
  """Prints out a sample of correct and incorrect predictions."""
  correct = []
  incorrect = []
  for target, prediction in zip(targets, predictions):
    if (target["targets"] == prediction["targets"] and
        len(correct) < SAMPLE_LENGTH):
      correct.append(
          TEMPLATE.format(
              index=len(correct),
              input=_escape_md(target["inputs"]),
              target=_escape_md(target["targets"]),
              prediction=_escape_md(prediction["targets"]),
          ))
    elif len(incorrect) < SAMPLE_LENGTH:
      incorrect.append(
          TEMPLATE.format(
              index=len(incorrect),
              input=_escape_md(target["inputs"]),
              target=_escape_md(target["targets"]),
              prediction=_escape_md(prediction["targets"]),
          ))
  correct_text = seqio.metrics.Text(textdata="\n".join(correct))
  incorrect_text = seqio.metrics.Text(textdata="\n".join(incorrect))
  return {
      "correct_predictions": correct_text,
      "incorrect_predictions": incorrect_text
  }
Prints out a sample of correct and incorrect predictions.
language/fruit/metrics.py