code: def topng(images, path, prefix="image", overwrite=False, credentials=None):
      
      value_shape = images.value_shape
      if not len(value_shape) in [2, 3]:
          raise ValueError("Only 2D or 3D images can be exported to png, "
                           "images are %d-dimensional." % len(value_shape))
  
      from scipy.misc import imsave
      from io import BytesIO
      from thunder.writers import get_parallel_writer
  
      def tobuffer(kv):
          key, img = kv
          fname = prefix+"-"+"%05d.png" % int(key)
          bytebuf = BytesIO()
          imsave(bytebuf, img, format='PNG')
          return fname, bytebuf.getvalue()
  
      writer = get_parallel_writer(path)(path, overwrite=overwrite, credentials=credentials)
      images.foreach(lambda x: writer.write(tobuffer(x)))
docs: Write out PNG files for 2d image data.
  
      See also
      --------
      thunder.data.images.topng