def process_feature(self, feature):
    """Write a InputFeature to the TFRecordWriter as a tf.train.Example."""
    self.num_features += 1

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

    def create_bytes_feature(value):
      return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))

    features = collections.OrderedDict()
    features["qas_ids"] = create_bytes_feature(feature.qas_id)
    features["qry_input_ids"] = create_int_feature(feature.qry_input_ids)
    features["qry_input_mask"] = create_int_feature(feature.qry_input_mask)
    features["qry_entity_id"] = create_int_feature(feature.qry_entity_id)

    if feature.relation_input_ids:
      for ii in range(len(feature.relation_input_ids)):
        features["rel_input_ids_%d" % ii] = create_int_feature(
            feature.relation_input_ids[ii])
        features["rel_input_mask_%d" % ii] = create_int_feature(
            feature.relation_input_mask[ii])

    if self.is_training:
      if feature.answer_mention is not None:
        features["answer_mentions"] = create_int_feature(feature.answer_mention)
      features["answer_entities"] = create_int_feature(feature.answer_entity)

    if self.has_bridge:
      if feature.bridge_mention is not None:
        features["bridge_mentions"] = create_int_feature(feature.bridge_mention)
      for ii, bridge_entity in enumerate(feature.bridge_entity):
        features["bridge_entities_%d" % ii] = create_int_feature(bridge_entity)

    tf_example = tf.train.Example(features=tf.train.Features(feature=features))
    self._writer.write(tf_example.SerializeToString())
Write a InputFeature to the TFRecordWriter as a tf.train.Example.
language/labs/drkit/input_fns.py