code: def pad_new(x, pad, mode="constant", value=0):
      new_pad = []
      for _ in range(x.ndim * 2 - len(pad)):
          new_pad.append(0)
      ndim = list(range(x.ndim - 1, 0, -1))
      axes_start = {}
      for i, _pad in enumerate(pad):
          if _pad < 0:
              new_pad.append(0)
              zhengshu, yushu = divmod(i, 2)
              if yushu == 0:
                  axes_start[ndim[zhengshu]] = -_pad
          else:
              new_pad.append(_pad)
  
      padded = paddle.nn.functional.pad(
          x, new_pad, mode=mode, value=value
      )
      padded_shape = paddle.shape(padded)
      axes = []
      starts = []
      ends = []
      for k, v in axes_start.items():
          axes.append(k)
          starts.append(v)
          ends.append(padded_shape[k])
          assert v < padded_shape[k]
  
      if axes:
          return padded.slice(axes=axes, starts=starts, ends=ends)
      else:
          return padded
  
imports: from functools import partial
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: pad_new(x, pad, mode, value) and returns: padded, padded