code: def _pt_pad(
      img: NdarrayTensor,
      pad_width: list[tuple[int, int]],
      mode: str,
      **kwargs,
  ) -> NdarrayTensor:
      img_pt = torch.as_tensor(img)
      mode = convert_pad_mode(dst=img_pt, mode=mode).value
      if mode == "constant" and "constant_values" in kwargs:
          _kwargs = kwargs.copy()
          _kwargs["value"] = _kwargs.pop("constant_values")
      else:
          _kwargs = kwargs
      pt_pad_width = [
          val for sublist in pad_width[1:] for val in sublist[::-1]
      ][::-1]
      # torch.pad expects `[B, C, H, W, [D]]` shape
      img_pt = pad_pt(
          img_pt.unsqueeze(0), pt_pad_width, mode=mode, **_kwargs
      ).squeeze(0)
      return convert_to_dst_type(img_pt, dst=img)[0]
  
file_path: MONAI/monai/transforms/croppad/functional.py
imports: from __future__ import annotations
  import warnings
  import numpy
  import torch
  from torch.nn.functional import pad
  from monai.config.type_definitions import NdarrayTensor
  from monai.data.meta_obj import get_track_meta
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import to_affine_nd
  from monai.transforms.inverse import TraceableTransform
  from monai.transforms.utils import convert_pad_mode, create_translate
  from monai.utils import PytorchPadMode, convert_to_dst_type, convert_to_numpy, convert_to_tensor, ensure_tuple
label_desc: Use image node_id 3 for calling a global function with example usage: _pt_pad(img, pad_width, mode) and returns: convert_to_dst_type