code: def _save(im, fp, filename):
      fp.write(_MAGIC)  # (2+2)
      sizes = im.encoderinfo.get(
          "sizes",
          [
              (16, 16),
              (24, 24),
              (32, 32),
              (48, 48),
              (64, 64),
              (128, 128),
              (256, 256),
          ],
      )
      width, height = im.size
      sizes = filter(
          lambda x: False
          if (x[0] > width or x[1] > height or x[0] > 256 or x[1] > 256)
          else True,
          sizes,
      )
      sizes = list(sizes)
      fp.write(struct.pack("<H", len(sizes)))  # idCount(2)
      offset = fp.tell() + len(sizes) * 16
      for size in sizes:
          width, height = size
          # 0 means 256
          fp.write(
              struct.pack("B", width if width < 256 else 0)
          )  # bWidth(1)
          fp.write(
              struct.pack("B", height if height < 256 else 0)
          )  # bHeight(1)
          fp.write(b"\0")  # bColorCount(1)
          fp.write(b"\0")  # bReserved(1)
          fp.write(b"\0\0")  # wPlanes(2)
          fp.write(struct.pack("<H", 32))  # wBitCount(2)
  
          image_io = BytesIO()
          tmp = im.copy()
          tmp.thumbnail(size, Image.LANCZOS)
          tmp.save(image_io, "png")
          image_io.seek(0)
          image_bytes = image_io.read()
          bytes_len = len(image_bytes)
          fp.write(struct.pack("<I", bytes_len))  # dwBytesInRes(4)
          fp.write(struct.pack("<I", offset))  # dwImageOffset(4)
          current = fp.tell()
          fp.seek(offset)
          fp.write(image_bytes)
          offset = offset + bytes_len
          fp.seek(current)
  
imports: import struct
  import warnings
  from io import BytesIO
  from math import ceil, log
  from .None import BmpImagePlugin, Image, ImageFile, PngImagePlugin
  from ._binary import i8, i16le, i32le
label_desc: Use image node_id 1 for calling a global function with example usage: _save(im, fp, filename) without return types