def file_based_convert_examples_to_features_single(examples, label_list,
                                                   max_seq_length, tokenizer,
                                                   output_file):
  """Convert a set of `InputExample`s to a TFRecord file."""

  writer = tf.python_io.TFRecordWriter(output_file)

  ex_index = 0
  for example in examples:
    if ex_index % 10000 == 0:
      tf.logging.info("Writing example " + str(ex_index))

    feature = convert_single_example(ex_index, example, max_seq_length,
                                     tokenizer, label_list)
    ex_index = ex_index + 1

    def create_int_feature(values):
      f = tf.train.Feature(int64_list=tf.train.Int64List(value=list(values)))
      return f

    def create_float_feature(values):
      f = tf.train.Feature(float_list=tf.train.FloatList(value=list(values)))
      return f

    features = collections.OrderedDict()

    p_ids = []
    q_ids = []

    for qp in feature.unique_ids:
      elems = qp.split("-")
      q_id = int(elems[0])
      p_id = int(elems[1])
      p_ids.append(p_id)
      q_ids.append(q_id)

    features["q_ids"] = create_int_feature(q_ids)
    features["cand_nums"] = create_int_feature(p_ids)
    features["input_ids"] = create_int_feature(feature.input_ids)
    features["input_mask"] = create_int_feature(feature.input_masks)
    features["segment_ids"] = create_int_feature(feature.segment_ids)
    features["label_ids"] = create_int_feature(feature.label_ids)
    features["scores"] = create_float_feature(feature.scores)

    tf_example = tf.train.Example(features=tf.train.Features(feature=features))
    writer.write(tf_example.SerializeToString())
  writer.close()
  print("Wrote " + str(ex_index) + " examples " + output_file)
Convert a set of `InputExample`s to a TFRecord file.
language/multivec/preprocessing/create_training_data.py