code: def gen_image(img, width, height, outfile, img_type='grey'):
      
      assert len(img) == width * height or len(img) == width * height * 3
  
      if img_type == 'grey':
          misc.imsave(outfile, img.reshape(width, height))
  
      elif img_type == 'color':
          misc.imsave(outfile, img.reshape(3, width, height))
docs: Save an image with the given parameters.