def text2text_txt_iterator_with_index(source_txt_path, target_txt_path):
  """Yield dicts for Text2TextProblem.generate_samples from lines of files."""
  for (idx, (inputs, targets)) in enumerate(zip(
      txt_line_iterator(source_txt_path),
      txt_line_iterator(target_txt_path))):
    yield {"inputs": inputs, "targets": targets, "idx": [idx]}
Yield dicts for Text2TextProblem.generate_samples from lines of files.
tensor2tensor/data_generators/text_problems.py