def creation_wrapper(process_dataset_fn):
  """Wrapper for creating the TFRecords files."""
  # Create the tf examples directory.
  if not tf.gfile.IsDirectory(FLAGS.tf_examples_dir):
    print('Creating TFExamples directory at ' + FLAGS.tf_examples_dir)
    tf.gfile.MkDir(FLAGS.tf_examples_dir)

  # Get the model config.
  model_config = load_config(FLAGS.config)

  for filename in FLAGS.filenames:
    if not filename:
      continue

    input_path = os.path.join(FLAGS.examples_dir, filename)
    output_path = os.path.join(
        FLAGS.tf_examples_dir,
        filename.split('/')[-1].split('.')[0] + '.tfrecords')

    permute = 'spider_train' in output_path and FLAGS.permute
    num_repeats = FLAGS.num_spider_repeats if permute else 1

    print('Processing %s. Permute: %r with %d repetitions' %
          (filename, permute, num_repeats))
    print('Writing to ' + output_path)

    process_dataset_fn(input_path, model_config, permute, num_repeats,
                       output_path)
Wrapper for creating the TFRecords files.
language/xsp/data_preprocessing/convert_to_tfrecords.py