code: def check_image_size(dataset_dict, image):
      """
      Raise an error if the image does not match the size specified in the dict.
      """
      if "width" in dataset_dict or "height" in dataset_dict:
          image_wh = (image.shape[1], image.shape[0])
          expected_wh = (dataset_dict["width"], dataset_dict["height"])
          if not image_wh == expected_wh:
              raise SizeMismatchError(
                  "Mismatched image shape{}, got {}, expect {}.".format(
                      " for image " + dataset_dict["file_name"]
                      if "file_name" in dataset_dict
                      else "",
                      image_wh,
                      expected_wh,
                  )
                  + " Please check the width/height in your annotation."
              )
  
      # To ensure bbox always remap to original image size
      if "width" not in dataset_dict:
          dataset_dict["width"] = image.shape[1]
      if "height" not in dataset_dict:
          dataset_dict["height"] = image.shape[0]
  
imports: import logging
  import numpy
  from typing import List, Union
  import pycocotools.mask
  import torch
  from PIL import Image
  from detectron2.structures import BitMasks, Boxes, BoxMode, Instances, Keypoints, PolygonMasks, RotatedBoxes, polygons_to_bitmask
  from detectron2.utils.file_io import PathManager
  from .None import transforms
  from .catalog import MetadataCatalog
label_desc: Use image node_id 5 for calling a global function with example usage: check_image_size(dataset_dict, image) without return types