def process_feature(self, feature: preproc.InputFeatures) -> None:
    """Writes InputFeatures to the TFRecordWriter as a tf.train.Example."""
    self.num_features += 1

    def create_int_feature(values: Sequence[int]) -> tf.train.Feature:
      return tf.train.Feature(int64_list=tf.train.Int64List(value=list(values)))

    # This needs to be kept in sync with `input_fn_builder`.
    features = collections.OrderedDict()
    features["unique_ids"] = create_int_feature([feature.unique_id])
    features["input_ids"] = create_int_feature(feature.input_ids)
    features["input_mask"] = create_int_feature(feature.input_mask)
    features["segment_ids"] = create_int_feature(feature.segment_ids)
    features["language_id"] = create_int_feature([feature.language_id])

    if self.is_training:
      features["start_positions"] = create_int_feature([feature.start_position])
      features["end_positions"] = create_int_feature([feature.end_position])
      features["answer_types"] = create_int_feature([feature.answer_type])
    else:
      features["wp_start_offset"] = create_int_feature(feature.wp_start_offset)
      features["wp_end_offset"] = create_int_feature(feature.wp_end_offset)

    tf_example = tf.train.Example(features=tf.train.Features(feature=features))
    self._writer.write(tf_example.SerializeToString())
Writes InputFeatures to the TFRecordWriter as a tf.train.Example.
language/canine/tydiqa/tf_io.py