code: def fw_pad(x, fw, pad_sz, pad_mode, dim=0):
      if pad_sz == (0, 0):
          return x
      if fw is numpy:
          pad_vec = [(0, 0)] * x.ndim
          pad_vec[dim] = pad_sz
          return fw.pad(x, pad_width=pad_vec, mode=pad_mode)
      else:
          if x.ndim < 3:
              x = x[None, None, ...]
  
          pad_vec = [0] * ((x.ndim - 2) * 2)
          pad_vec[0:2] = pad_sz
          return fw_swapaxes(
              fw.nn.functional.pad(
                  fw_swapaxes(x, dim, -1, fw),
                  pad=pad_vec,
                  mode=pad_mode,
              ),
              dim,
              -1,
              fw,
          )
  
imports: import warnings
  from fractions import Fraction
  from math import ceil
  from typing import Tuple
  import disco_diffusion_clip_rn50.resize_right.interp_methods
label_desc: Use image node_id 14 for calling a global function with example usage: fw_pad(x, fw, pad_sz, pad_mode, dim) and returns: x, fw, fw_swapaxes