code: def _pad_array(array, pad_sizes):
      """Pad an array with zeros.
  
      Pads an array with zeros as specified in `pad_sizes`.
  
      Parameters
      ----------
      array : :class:`numpy.ndarray`
          Array to pad.
  
      pad_sizes : :obj:`list`
          Padding quantity specified as
          *[x1minpad, x1maxpad, x2minpad,x2maxpad, x3minpad, ...]*.
  
      Returns
      -------
      :class:`numpy.ndarray`
          Padded array.
  
      Raises
      ------
      ValueError
          Inconsistent min/max padding quantities.
  
      """
      if len(pad_sizes) % 2 != 0:
          raise ValueError(
              "Please specify as many max paddings as min"
              f" paddings. You have specified {len(pad_sizes)} arguments"
          )
  
      all_paddings = np.zeros([array.ndim, 2], dtype=np.int64)
      all_paddings[: len(pad_sizes) // 2] = np.array(pad_sizes).reshape(
          -1, 2
      )
  
      lower_paddings, upper_paddings = all_paddings.T
      new_shape = (
          np.array(array.shape) + upper_paddings + lower_paddings
      )
  
      padded = np.zeros(new_shape, dtype=array.dtype)
      source_slices = [
          slice(max(-lp, 0), min(s + up, s))
          for lp, up, s in zip(
              lower_paddings, upper_paddings, array.shape
          )
      ]
      target_slices = [
          slice(max(lp, 0), min(s - up, s))
          for lp, up, s in zip(
              lower_paddings, upper_paddings, new_shape
          )
      ]
  
      padded[tuple(target_slices)] = array[tuple(source_slices)].copy()
      return padded
  
imports: import collections.abc
  import copy
  import itertools
  import warnings
  import nibabel
  import numpy
  from joblib import Memory, Parallel, delayed
  from scipy.ndimage import gaussian_filter1d, generate_binary_structure, label
  from scipy.stats import scoreatpercentile
  from ..None import signal
  from .._utils import _repr_niimgs, as_ndarray, check_niimg, check_niimg_3d, check_niimg_4d, fill_doc
  from .._utils.exceptions import DimensionError
  from .._utils.helpers import rename_parameters, stringify_path
  from .._utils.niimg import _get_data, safe_get_data
  from .._utils.niimg_conversions import _index_img, check_same_fov, iter_check_niimg
  from .._utils.param_validation import check_threshold
  from .._utils.path_finding import resolve_globbing
label_desc: Use image node_id 8 for calling a global function with example usage: _pad_array(array, pad_sizes) and returns: padded