def merge_predictions(examples, filename):
  """Merge multiple predcition files into one."""
  source_to_prediction = {}
  output_files = gfile.glob("%s-*-of-*" % filename)
  for output_file in output_files:
    predictions = tsv_utils.read_tsv(output_file)
    for prediction in predictions:
      source, predicted_target = prediction
      source_to_prediction[source] = predicted_target
  new_predictions = []
  for example in examples:
    new_predictions.append((source_to_prediction[example[0]]))
  txt_utils.write_txt(new_predictions, filename)
Merge multiple predcition files into one.
language/compgen/csl/model/inference/eval_model_beam.py