code: def assert_image(im, mode, size, msg=None):
      if mode is not None:
          assert im.mode == mode, (
              msg or f"got mode {repr(im.mode)}, expected {repr(mode)}"
          )
  
      if size is not None:
          assert im.size == size, (
              msg or f"got size {repr(im.size)}, expected {repr(size)}"
          )
  
imports: import logging
  import os
  import shutil
  import sys
  import sysconfig
  import tempfile
  from io import BytesIO
  import pytest
  from packaging.version import parse
  from PIL import Image, ImageMath, features
label_desc: Use image node_id 3 for calling a global function with example usage: assert_image(im, mode, size, msg) without return types