code: def save_img(encoded, step, save_gif):
      from PIL import Image
  
      img = Image.open(io.BytesIO(encoded))
      if save_gif:
          images.append(img)
      else:
          img.save("img_{}.png".format(step), format="png")
  
imports: import struct
  import tensorboard.compat.proto.event_pb2
  import io
  import argparse
label_desc: Use image node_id 2 for calling a global function with example usage: save_img(encoded, step, save_gif) without return types