code: def _resample_fft(
      x_flat, *, ratio, final_len, pad, window, npad, n_jobs
  ):
      x_len = x_flat.shape[-1]
      pad = "reflect_limited" if pad == "auto" else pad
      if (
          isinstance(window, str) and window == "auto"
      ) or window is None:
          window = "boxcar"
      if isinstance(npad, str):
          _check_option("npad", npad, ("auto",), extra="when a string")
          # Figure out reasonable pad that gets us to a power of 2
          min_add = min(x_len // 8, 100) * 2
          npad = 2 ** int(np.ceil(np.log2(x_len + min_add))) - x_len
          npad, extra = divmod(npad, 2)
          npads = np.array([npad, npad + extra], int)
      else:
          npad = _ensure_int(npad, "npad", extra="or 'auto'")
          npads = np.array([npad, npad], int)
      del npad
  
      # prep for resampling now
      orig_len = x_len + npads.sum()  # length after padding
      new_len = max(
          int(round(ratio * orig_len)), 1
      )  # length after resampling
      to_removes = [int(round(ratio * npads[0]))]
      to_removes.append(new_len - final_len - to_removes[0])
      to_removes = np.array(to_removes)
      # This should hold:
      # assert np.abs(to_removes[1] - to_removes[0]) <= int(np.ceil(ratio))
  
      # figure out windowing function
      if callable(window):
          W = window(fft.fftfreq(orig_len))
      elif isinstance(window, np.ndarray) and window.shape == (
          orig_len,
      ):
          W = window
      else:
          W = fft.ifftshift(signal.get_window(window, orig_len))
      W *= float(new_len) / float(orig_len)
  
      # figure out if we should use CUDA
      n_jobs, cuda_dict = _setup_cuda_fft_resample(n_jobs, W, new_len)
  
      # do the resampling using an adaptation of scipy's FFT-based resample()
      # use of the 'flat' window is recommended for minimal ringing
      parallel, p_fun, n_jobs = parallel_func(_fft_resample, n_jobs)
      if n_jobs == 1:
          y = np.zeros(
              (len(x_flat), new_len - to_removes.sum()),
              dtype=x_flat.dtype,
          )
          for xi, x_ in enumerate(x_flat):
              y[xi] = _fft_resample(
                  x_, new_len, npads, to_removes, cuda_dict, pad
              )
      else:
          y = parallel(
              p_fun(x_, new_len, npads, to_removes, cuda_dict, pad)
              for x_ in x_flat
          )
          y = np.array(y)
  
      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 27 for calling a global function with example usage: _resample_fft(x_flat) and returns: y