code: def preprocess_images(
      input_images: list[Tensor] | Tensor,
      spatial_dims: int,
      size_divisible: int | Sequence[int],
      mode: PytorchPadMode | str = PytorchPadMode.CONSTANT,
      **kwargs: Any,
  ) -> tuple[Tensor, list[list[int]]]:
      """
      Preprocess the input images, including
  
      - validate of the inputs
      - pad the inputs so that the output spatial sizes are divisible by `size_divisible`.
        It pads them at the end to create a (B, C, H, W) or (B, C, H, W, D) Tensor.
        Padded size (H, W) or (H, W, D) is divisible by size_divisible.
        Default padding uses constant padding with value 0.0
  
      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.
          size_divisible: int or Sequence[int], is the expected pattern on the input image shape.
              If an int, the same `size_divisible` will be applied to all the input spatial dimensions.
          mode: available modes for PyTorch Tensor: {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}.
              One of the listed string values or a user supplied function. Defaults to ``"constant"``.
              See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
          kwargs: other arguments for `torch.pad` function.
  
      Return:
          - images, a (B, C, H, W) or (B, C, H, W, D) Tensor
          - image_sizes, the original spatial size of each image
      """
      check_input_images(input_images, spatial_dims)
      size_divisible = ensure_tuple_rep(size_divisible, spatial_dims)
  
      return pad_images(
          input_images, spatial_dims, size_divisible, mode, **kwargs
      )
  
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 4 for calling a global function with example usage: preprocess_images(input_images, spatial_dims, size_divisible, mode) and returns: pad_images