def write_references(references, output_path_base):
  """Write single and multiple references to file."""
  # Just write a single reference file for now.
  with open(output_path_base, "w", encoding="utf-8") as f:
    for multi_reference in references:
      f.write(multi_reference[0].lower() + "\n")

  # Write out multireferences.
  if FLAGS.mode == "dev" or FLAGS.mode == "test":
    output_path_multi0 = output_path_base + "-multi0"
    with open(output_path_multi0, "w", encoding="utf-8") as f:
      for multi_reference in references:
        f.write(multi_reference[0].lower() + "\n")

    output_path_multi1 = output_path_base + "-multi1"
    with open(output_path_multi1, "w", encoding="utf-8") as f:
      for multi_reference in references:
        f.write(multi_reference[1].lower() + "\n")

    output_path_multi2 = output_path_base + "-multi2"
    with open(output_path_multi2, "w", encoding="utf-8") as f:
      for multi_reference in references:
        f.write(multi_reference[2].lower() + "\n")
Write single and multiple references to file.
language/totto/prepare_references_for_eval.py