def write_to_files_rec(instances, tokenizer, max_seq_length,<EOL>max_predictions_per_seq, output_files):
writers = []<EOL>for output_file in output_files:<EOL><INDENT>writers.append(<EOL>mx.recordio.MXIndexedRecordIO(<EOL>os.path.splitext(output_file)[<NUM_LIT:0>] + '<STR_LIT>', output_file, '<STR_LIT:w>'))<EOL><DEDENT>writer_index = <NUM_LIT:0><EOL>total_written = <NUM_LIT:0><EOL>for (inst_index, instance) in enumerate(instances):<EOL><INDENT>features = transform(instance, tokenizer, max_seq_length, max_predictions_per_seq)<EOL>example = features<EOL>writers[writer_index].write_idx(inst_index, json.dumps(example).encode('<STR_LIT>'))<EOL>writer_index = (writer_index + <NUM_LIT:1>) % len(writers)<EOL>total_written += <NUM_LIT:1><EOL><DEDENT>for writer in writers:<EOL><INDENT>writer.close()<EOL><DEDENT>logging.info('<STR_LIT>', total_written)<EOL>
Create IndexedRecordIO files from `TrainingInstance`s.