import tensorflow as tf

    return f

  features = collections.OrderedDict()
  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["label_ids"] = create_int_feature([feature.label_id])
  features["is_real_example"] = create_int_feature(
    [int(feature.is_real_example)])
  tf_example = tf.train.Example(features=tf.train.Features(feature=features))
  return tf_example


def file_based_input_fn_builder(input_file, seq_length, is_training,
                                drop_remainder):
  """Creates an `input_fn` closure to be passed to TPUEstimator."""

  name_to_features = {
