code: def _pad_array(
      arr: np.array,
      pad_width: Union[
          int,
          Sequence[int],
          Sequence[Tuple[int]],
          List[Tuple[int, int]],
      ],
      mode: str,
      padded_axes: Sequence[int],
  ) -> np.array:
      """
      Pad an array according to the mode.
  
      Parameters
      ----------
      arr: np.ndarray
           Array to pad.
      pad_width: int, sequence
              The size of the padding.
      mode: string
          numpy.pad mode (see https://numpy.org/doc/stable/reference/generated/numpy.pad.html)
      padded_axes: sequence
          Indices of axes to pad.
  
      Returns
      -------
      np.ndarray
          Padded array.
      """
  
      assert (
          len(padded_axes) <= arr.ndim
      ), "Cannot pad more axes than array has dimensions"
  
      if isinstance(pad_width, Sequence):
          assert len(pad_width) == len(
              padded_axes
          ), "pad_width and padded_axes have different lengths"
          for p in pad_width:
              if isinstance(p, tuple):
                  assert (
                      len(p) == 2
                  ), "Elements in pad_width need to have length 2"
  
      pad_width_list: List[Union[Tuple[int], Tuple[int, int]]] = []
  
      for ax in range(arr.ndim):
          if ax not in padded_axes:
              pad_width_list.append((0, 0))
          elif isinstance(pad_width, int):
              pad_width_list.append((pad_width, pad_width))
          elif isinstance(
              pad_width[[p for p in padded_axes].index(ax)], int
          ):
              pad_width_list.append(
                  (
                      pad_width[[p for p in padded_axes].index(ax)],
                      pad_width[[p for p in padded_axes].index(ax)],
                  )
              )
          else:
              pad_width_list.append(
                  pad_width[[p for p in padded_axes].index(ax)]
              )
  
      arr_pad = np.pad(arr, pad_width_list, mode=mode)
  
      return arr_pad
  
imports: import copy
  import re
  from importlib import util
  from typing import Any, Dict, Optional, Sequence, Tuple, Union, List, TypeVar
  import numpy
  from skimage.segmentation import slic, felzenszwalb
  from quantus.helpers import asserts
  from quantus.helpers.model.model_interface import ModelInterface
label_desc: Use image node_id 14 for calling a global function with example usage: _pad_array(arr, pad_width, mode, padded_axes) and returns: arr_pad