code: def convert_to(data_set, name):
      """Converts a dataset to tfrecords."""
      images = data_set.images
      labels = data_set.labels
      num_examples = data_set.num_examples
  
      if images.shape[0] != num_examples:
          raise ValueError(
              "Images size %d does not match label size %d."
              % (images.shape[0], num_examples)
          )
      rows = images.shape[1]
      cols = images.shape[2]
      depth = images.shape[3]
  
      filename = os.path.join(FLAGS.directory, name + ".tfrecords")
      print("Writing", filename)
      with tf.python_io.TFRecordWriter(filename) as writer:
          for index in range(num_examples):
              image_raw = images[index].tostring()
              example = tf.train.Example(
                  features=tf.train.Features(
                      feature={
                          "height": _int64_feature(rows),
                          "width": _int64_feature(cols),
                          "depth": _int64_feature(depth),
                          "label": _int64_feature(int(labels[index])),
                          "image_raw": _bytes_feature(image_raw),
                      }
                  )
              )
              writer.write(example.SerializeToString())
  
file_path: attributionpriors/attributionpriors/mnist/mnist_download.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import os
  import sys
  import tensorflow
  from tensorflow.contrib.learn.python.learn.datasets import mnist
label_desc: Use image node_id 3 for calling a global function with example usage: convert_to(data_set, name) without return types