def METHOD_NAME(input_files, output_file, folder):
  """Converts files with pickled data to TFRecords."""
  assert folder in ['cifar-10', 'cifar-100']
  print('Generating %s' % output_file)
  with tf.python_io.TFRecordWriter(output_file) as record_writer:
    for input_file in input_files:
      data_dict = read_pickle_from_file(input_file)
      data = data_dict[b'data']
      try:
        labels = data_dict[b'labels']
      except KeyError:
        labels = data_dict[b'fine_labels']
      if folder == 'cifar-100' and input_file.endswith('train.tfrecords'):
        data = data[:40000]
        labels = labels[:40000]
      elif folder == 'cifar-100' and input_file.endswith(
          'validation.tfrecords'):
        data = data[40000:]
        labels = labels[40000:]
      num_entries_in_batch = len(labels)
      for i in range(num_entries_in_batch):
        example = tf.train.Example(
            features=tf.train.Features(
                feature={
                    'image': _bytes_feature(data[i].tobytes()),
                    'label': _int64_feature(labels[i])
                }))
        record_writer.write(example.SerializeToString())