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 image_wh != expected_wh:
              raise SizeMismatchError(
                  "Mismatched (W,H){}, got {}, expect {}".format(
                      " for image " + dataset_dict["file_name"]
                      if "file_name" in dataset_dict
                      else "",
                      image_wh,
                      expected_wh,
                  )
              )
  
      # 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 os
  import logging
  import numpy
  from PIL import Image
  import torch
  from ..structures import BitMasks, Boxes, BoxMode, Instances, Keypoints, PolygonMasks, polygons_to_bitmask
  from ..transforms import instance_transforms
  from ..registry.catalog import MetadataCatalog
label_desc: Use image node_id 8 for calling a global function with example usage: check_image_size(dataset_dict, image) without return types