code: def _smart_pad(x, n_pad, pad="reflect_limited"):
      """Pad vector x."""
      n_pad = np.asarray(n_pad)
      assert n_pad.shape == (2,)
      if (n_pad == 0).all():
          return x
      elif (n_pad < 0).any():
          raise RuntimeError("n_pad must be non-negative")
      if pad == "reflect_limited":
          # need to pad with zeros if len(x) <= npad
          l_z_pad = np.zeros(
              max(n_pad[0] - len(x) + 1, 0), dtype=x.dtype
          )
          r_z_pad = np.zeros(
              max(n_pad[1] - len(x) + 1, 0), dtype=x.dtype
          )
          return np.concatenate(
              [
                  l_z_pad,
                  2 * x[0] - x[n_pad[0] : 0 : -1],
                  x,
                  2 * x[-1] - x[-2 : -n_pad[1] - 2 : -1],
                  r_z_pad,
              ]
          )
      else:
          return np.pad(x, (tuple(n_pad),), pad)
  
file_path: mne-python/mne/cuda.py
imports: import numpy
  from scipy.fft import irfft, rfft
  from .utils import _check_option, _explain_exception, fill_doc, get_config, logger, sizeof_fmt, verbose, warn
label_desc: Use image node_id 11 for calling a global function with example usage: _smart_pad(x, n_pad, pad) and returns: x, np, np