code: def restore_bytes(nb):
      """Restore bytes of image data from unicode-only formats.
  
      Base64 encoding is handled elsewhere.  Bytes objects in the notebook are
      always b64-encoded. We DO NOT encode/decode around file formats.
  
      Note: this is never used
      """
      for ws in nb.worksheets:
          for cell in ws.cells:
              if cell.cell_type == "code":
                  for output in cell.outputs:
                      if "png" in output:
                          output.png = output.png.encode(
                              "ascii", "replace"
                          )
                      if "jpeg" in output:
                          output.jpeg = output.jpeg.encode(
                              "ascii", "replace"
                          )
      return nb
  
file_path: nbformat/nbformat/v3/rwbase.py
imports: from __future__ import annotations
  from base64 import decodebytes, encodebytes
label_desc: Use image node_id 1 for calling a global function with example usage: restore_bytes(nb) and returns: nb