code: def main():
      HERE = os.path.dirname(__file__)
  
      # Import MNIST data
      sys.path.append(
          os.path.realpath(
              os.path.join(HERE, "..", "..", "vision", "mnist")
          )
      )
      from mnist_data import data_iterator_mnist
  
      # Create binary output folder
      path_bin = os.path.join(HERE, "mnist_images")
      if not os.path.isdir(path_bin):
          os.makedirs(path_bin)
  
      # Get MNIST testing images.
      images, labels = data_iterator_mnist(
          10000, train=False, shuffle=True
      ).next()
  
      # Dump image binary files with row-major order.
      for i in range(10):
          outfile = os.path.join(path_bin, "{}.pgm".format(i))
          print(
              "Generator a binary file of number {} to {}".format(
                  i, outfile
              )
          )
          ind = np.where(labels == i)[0][0]
          image = images[ind].copy(order="C")
          with open(outfile, "w") as fd:
              print("P5", file=fd)
              print(
                  "# Created by nnabla mnist_runtime example.", file=fd
              )
              print("28 28", file=fd)
              print("255", file=fd)
              image.tofile(fd)
  
imports: from __future__ import print_function
  from six.moves import range
  import os
  import sys
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types