code: def save_as_png(val_array, img_file_name, dim=28):
      img_array = val_array.reshape((dim, dim))
      img_array = np.clip(img_array, 0, img_array.max())
      img_array *= 255.0 / img_array.max()
      img_array = np.rint(img_array).astype("uint8")
  
      try:
          os.remove(img_file_name)
      except OSError:
          pass
  
      im = Image.fromarray(img_array)
      im2 = im.resize((224, 224))
      im2.save(img_file_name)
  
file_path: CNTK/Examples/Image/GettingStarted/07_Deconvolution_Visualizer.py
imports: from __future__ import print_function
  import os, sys
  import numpy
  import argparse
  from cntk import load_model
  from cntk.ops import combine
  from cntk.io import MinibatchSource, CTFDeserializer, StreamDef, StreamDefs
  from PIL import Image
  from cntk.logging import graph
label_desc: Use image node_id 2 for calling a global function with example usage: save_as_png(val_array, img_file_name, dim) without return types