code: def check_input_images(
      input_images: list[Tensor] | Tensor, spatial_dims: int
  ) -> None:
      """
      Validate the input dimensionality (raise a `ValueError` if invalid).
  
      Args:
          input_images: It can be 1) a tensor sized (B, C, H, W) or  (B, C, H, W, D),
              or 2) a list of image tensors, each image i may have different size (C, H_i, W_i) or  (C, H_i, W_i, D_i).
          spatial_dims: number of spatial dimensions of the images, 2 or 3.
      """
      if isinstance(input_images, Tensor):
          if len(input_images.shape) != spatial_dims + 2:
              raise ValueError(
                  "When input_images is a Tensor, its need to be (spatial_dims + 2)-D."
                  f"In this case, it should be a {(spatial_dims + 2)}-D Tensor, got Tensor shape {input_images.shape}."
              )
      elif isinstance(input_images, list):
          for img in input_images:
              if len(img.shape) != spatial_dims + 1:
                  raise ValueError(
                      "When input_images is a List[Tensor], each element should have be (spatial_dims + 1)-D."
                      f"In this case, it should be a {(spatial_dims + 1)}-D Tensor, got Tensor shape {img.shape}."
                  )
      else:
          raise ValueError(
              "input_images needs to be a List[Tensor] or Tensor."
          )
      return
  
file_path: MONAI/monai/apps/detection/utils/detector_utils.py
imports: from __future__ import annotations
  import warnings
  from collections.abc import Sequence
  from typing import Any
  import torch
  import torch.nn.functional
  from torch import Tensor
  from monai.data.box_utils import standardize_empty_box
  from monai.transforms.croppad.array import SpatialPad
  from monai.transforms.utils import compute_divisible_spatial_size, convert_pad_mode
  from monai.utils import PytorchPadMode, ensure_tuple_rep
label_desc: Use image node_id 1 for calling a global function with example usage: check_input_images(input_images, spatial_dims) without return types