code: def pad_image_tensor(
      image_tensor: Tensor, pad_size: Union[int, Tuple[int, int]] = 32
  ) -> Tuple[Tensor, Tuple[int, int, int, int]]:
      """Pad input tensor to make it's height and width dividable by @pad_size
  
      :param image_tensor: 4D image tensor of shape NCHW
      :param pad_size: Pad size
      :return: Tuple of output tensor and pad params. Second argument can be used to reverse pad operation of model output
      """
      if len(image_tensor.size()) != 4:
          raise ValueError("Tensor must have rank 4 ([B,C,H,W])")
  
      rows, cols = image_tensor.size(2), image_tensor.size(3)
      if (
          isinstance(pad_size, Sized)
          and isinstance(pad_size, Iterable)
          and len(pad_size) == 2
      ):
          pad_height, pad_width = [int(val) for val in pad_size]
      elif isinstance(pad_size, int):
          pad_height = pad_width = pad_size
      else:
          raise ValueError(
              f"Unsupported pad_size: {pad_size}, must be either tuple(pad_rows,pad_cols) or single int scalar."
          )
  
      if rows > pad_height:
          pad_rows = rows % pad_height
          pad_rows = pad_height - pad_rows if pad_rows > 0 else 0
      else:
          pad_rows = pad_height - rows
  
      if cols > pad_width:
          pad_cols = cols % pad_width
          pad_cols = pad_width - pad_cols if pad_cols > 0 else 0
      else:
          pad_cols = pad_width - cols
  
      if pad_rows == 0 and pad_cols == 0:
          return image_tensor, (0, 0, 0, 0)
  
      pad_top = pad_rows // 2
      pad_btm = pad_rows - pad_top
  
      pad_left = pad_cols // 2
      pad_right = pad_cols - pad_left
  
      pad = [pad_left, pad_right, pad_top, pad_btm]
      image_tensor = torch.nn.functional.pad(image_tensor, pad)
      return image_tensor, pad
  
imports: import itertools
  from collections.abc import Sized, Iterable
  from typing import Union, Tuple
  import torch
  from torch import Tensor
  from ..utils.support import pytorch_toolbelt_deprecated
label_desc: Use image node_id 19 for calling a global function with example usage: pad_image_tensor(image_tensor, pad_size) and returns: image_tensor,  pad, image_tensor,  int,  int,  int,  int