import tensorflow as tf

          break
        output_line = "\t".join(
            str(class_probability)
            for class_probability in probabilities) + "\n"
        writer.write(output_line)
        num_written_lines += 1
    assert num_written_lines == num_actual_predict_examples

  if FLAGS.do_serve:

    def serving_input_fn():
      with tf.variable_scope("foo"):
        feature_spec = {
            "input_ids": tf.FixedLenFeature([FLAGS.max_seq_length], tf.int64),
            "input_mask": tf.FixedLenFeature([FLAGS.max_seq_length], tf.int64),
            "segment_ids": tf.FixedLenFeature([FLAGS.max_seq_length], tf.int64),
            "label_ids": tf.FixedLenFeature([], tf.int64),
          }
        serialized_tf_example = tf.placeholder(dtype=tf.string,
                                               shape=[None],
                                               name='input_example_tensor')
        receiver_tensors = {'examples': serialized_tf_example}
        features = tf.parse_example(serialized_tf_example, feature_spec)
        return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)

    estimator._export_to_tpu = False  # this is important
