code: def to_bytes_format(im: Image.Image, format="png"):
      "Convert to bytes, default to PNG format"
      arr = io.BytesIO()
      im.save(arr, format=format)
      return arr.getvalue()
  
imports: from __future__ import annotations
  from ..torch_basics import *
  from ..data.all import *
  from PIL import Image
  from matplotlib import patches, patheffects
label_desc: Use image node_id 6 for calling a global function with example usage: to_bytes_format(im, format) and returns: arr