code: def saveImage(fname, data, label, mapFile, pad, **key_parms):
      # data in CIFAR-10 dataset is in CHW format.
      pixData = data.reshape((3, imgSize, imgSize))
      if "mean" in key_parms:
          key_parms["mean"] += pixData
  
      if pad > 0:
          pixData = np.pad(
              pixData,
              ((0, 0), (pad, pad), (pad, pad)),
              mode="constant",
              constant_values=128,
          )  # can also use mode='edge'
  
      img = Image.new("RGB", (imgSize + 2 * pad, imgSize + 2 * pad))
      pixels = img.load()
      for x in range(img.size[0]):
          for y in range(img.size[1]):
              pixels[x, y] = (
                  pixData[0][y][x],
                  pixData[1][y][x],
                  pixData[2][y][x],
              )
      img.save(fname)
      mapFile.write("%s\t%d\n" % (fname, label))
  
file_path: CNTK/Tutorials/ImageHandsOn/CifarConverter.py
imports: from __future__ import print_function
  import os
  import sys
  import struct
  import pickle
  from PIL import Image
  import numpy
  import xml.etree.cElementTree
  import xml.dom.minidom
label_desc: Use image node_id 1 for calling a global function with example usage: saveImage(fname, data, label, mapFile, pad) without return types