code: def resample(
      x,
      up=1.0,
      down=1.0,
      *,
      axis=-1,
      window="auto",
      n_jobs=None,
      pad="auto",
      npad=100,
      method="fft",
      verbose=None,
  ):
      """Resample an array.
  
      Operates along the last dimension of the array.
  
      Parameters
      ----------
      x : ndarray
          Signal to resample.
      up : float
          Factor to upsample by.
      down : float
          Factor to downsample by.
      axis : int
          Axis along which to resample (default is the last axis).
      %(window_resample)s
      %(n_jobs_cuda)s
          ``n_jobs='cuda'`` is only supported when ``method="fft"``.
      %(pad_resample_auto)s
  
          .. versionadded:: 0.15
      %(npad_resample)s
      %(method_resample)s
  
          .. versionadded:: 1.7
      %(verbose)s
  
      Returns
      -------
      y : array
          The x array resampled.
  
      Notes
      -----
      When using ``method="fft"`` (default),
      this uses (hopefully) intelligent edge padding and frequency-domain
      windowing improve :func:`scipy.signal.resample`'s resampling method, which
      we have adapted for our use here. Choices of npad and window have
      important consequences, and the default choices should work well
      for most natural signals.
      """
      _validate_type(method, str, "method")
      _validate_type(pad, str, "pad")
      _check_option("method", method, ("fft", "polyphase"))
  
      # make sure our arithmetic will work
      x = _check_filterable(x, "resampled", "resample")
      ratio, final_len = _resamp_ratio_len(up, down, x.shape[axis])
      del up, down
      if axis < 0:
          axis = x.ndim + axis
      if x.shape[axis] == 0:
          warn(
              f"x has zero length along axis={axis}, returning a copy of x"
          )
          return x.copy()
  
      # prep for resampling along the last axis (swap axis with last then reshape)
      out_shape = list(x.shape)
      out_shape.pop(axis)
      out_shape.append(final_len)
      x = np.atleast_2d(
          x.swapaxes(axis, -1).reshape((-1, x.shape[axis]))
      )
  
      # do the resampling using FFT or polyphase methods
      kwargs = dict(pad=pad, window=window, n_jobs=n_jobs)
      if method == "fft":
          y = _resample_fft(
              x, npad=npad, ratio=ratio, final_len=final_len, **kwargs
          )
      else:
          up, down, kwargs["window"] = _prep_polyphase(
              ratio, x.shape[-1], final_len, window
          )
          half_len = len(window) // 2
          logger.info(
              f"Polyphase resampling neighborhood: ±{half_len} "
              f"input sample{_pl(half_len)}"
          )
          y = _resample_polyphase(x, up=up, down=down, **kwargs)
      assert y.shape[-1] == final_len
  
      # restore dimensions (reshape then swap axis with last)
      y = y.reshape(out_shape).swapaxes(axis, -1)
  
      return y
  
imports: from collections import Counter
  from copy import deepcopy
  from functools import partial
  from math import gcd
  import numpy
  from scipy import fft, signal
  from scipy.stats import f
  from ._fiff.pick import _picks_to_idx
  from ._ola import _COLA
  from .cuda import _fft_multiply_repeated, _fft_resample, _setup_cuda_fft_multiply_repeated, _setup_cuda_fft_resample, _smart_pad
  from .parallel import parallel_func
  from .utils import _check_option, _check_preload, _ensure_int, _pl, _validate_type, logger, sum_squared, verbose, warn
label_desc: Use image node_id 24 for calling a global function with example usage: resample(x, up, down) and returns: y, x