code: def create_filter(
      data,
      sfreq,
      l_freq,
      h_freq,
      filter_length="auto",
      l_trans_bandwidth="auto",
      h_trans_bandwidth="auto",
      method="fir",
      iir_params=None,
      phase="zero",
      fir_window="hamming",
      fir_design="firwin",
      verbose=None,
  ):
      r"""Create a FIR or IIR filter.
  
      ``l_freq`` and ``h_freq`` are the frequencies below which and above
      which, respectively, to filter out of the data. Thus the uses are:
  
          * ``l_freq < h_freq``: band-pass filter
          * ``l_freq > h_freq``: band-stop filter
          * ``l_freq is not None and h_freq is None``: high-pass filter
          * ``l_freq is None and h_freq is not None``: low-pass filter
  
      Parameters
      ----------
      data : ndarray, shape (..., n_times) | None
          The data that will be filtered. This is used for sanity checking
          only. If None, no sanity checking related to the length of the signal
          relative to the filter order will be performed.
      sfreq : float
          The sample frequency in Hz.
      %(l_freq)s
      %(h_freq)s
      %(filter_length)s
      %(l_trans_bandwidth)s
      %(h_trans_bandwidth)s
      %(method_fir)s
      %(iir_params)s
      %(phase)s
      %(fir_window)s
      %(fir_design)s
      %(verbose)s
  
      Returns
      -------
      filt : array or dict
          Will be an array of FIR coefficients for method='fir', and dict
          with IIR parameters for method='iir'.
  
      See Also
      --------
      filter_data
  
      Notes
      -----
      .. note:: For FIR filters, the *cutoff frequency*, i.e. the -6 dB point,
                is in the middle of the transition band (when using phase='zero'
                and fir_design='firwin'). For IIR filters, the cutoff frequency
                is given by ``l_freq`` or ``h_freq`` directly, and
                ``l_trans_bandwidth`` and ``h_trans_bandwidth`` are ignored.
  
      **Band-pass filter**
  
      The frequency response is (approximately) given by::
  
         1-|               ----------
           |             /|         | \
       |H| |            / |         |  \
           |           /  |         |   \
           |          /   |         |    \
         0-|----------    |         |     --------------
           |         |    |         |     |            |
           0        Fs1  Fp1       Fp2   Fs2          Nyq
  
      Where:
  
          * Fs1 = Fp1 - l_trans_bandwidth in Hz
          * Fs2 = Fp2 + h_trans_bandwidth in Hz
  
      **Band-stop filter**
  
      The frequency response is (approximately) given by::
  
          1-|---------                   ----------
            |         \                 /
        |H| |          \               /
            |           \             /
            |            \           /
          0-|             -----------
            |        |    |         |    |        |
            0       Fp1  Fs1       Fs2  Fp2      Nyq
  
      Where ``Fs1 = Fp1 + l_trans_bandwidth`` and
      ``Fs2 = Fp2 - h_trans_bandwidth``.
  
      Multiple stop bands can be specified using arrays.
  
      **Low-pass filter**
  
      The frequency response is (approximately) given by::
  
          1-|------------------------
            |                        \
        |H| |                         \
            |                          \
            |                           \
          0-|                            ----------------
            |                       |    |              |
            0                      Fp  Fstop           Nyq
  
      Where ``Fstop = Fp + trans_bandwidth``.
  
      **High-pass filter**
  
      The frequency response is (approximately) given by::
  
          1-|             -----------------------
            |            /
        |H| |           /
            |          /
            |         /
          0-|---------
            |        |    |                     |
            0      Fstop  Fp                   Nyq
  
      Where ``Fstop = Fp - trans_bandwidth``.
  
      .. versionadded:: 0.14
      """
      sfreq = float(sfreq)
      if sfreq < 0:
          raise ValueError("sfreq must be positive")
      # If no data specified, sanity checking will be skipped
      if data is None:
          logger.info(
              "No data specified. Sanity checks related to the length of the signal "
              "relative to the filter order will be skipped."
          )
      if h_freq is not None:
          h_freq = np.array(h_freq, float).ravel()
          if (h_freq > (sfreq / 2.0)).any():
              raise ValueError(
                  f"h_freq ({h_freq}) must be less than the Nyquist frequency "
                  f"{sfreq / 2.0}"
              )
      if l_freq is not None:
          l_freq = np.array(l_freq, float).ravel()
          if (l_freq == 0).all():
              l_freq = None
      iir_params, method = _check_method(method, iir_params)
      if l_freq is None and h_freq is None:
          (
              data,
              sfreq,
              _,
              _,
              _,
              _,
              filter_length,
              phase,
              fir_window,
              fir_design,
          ) = _triage_filter_params(
              data,
              sfreq,
              None,
              None,
              None,
              None,
              filter_length,
              method,
              phase,
              fir_window,
              fir_design,
          )
          if method == "iir":
              out = (
                  dict() if iir_params is None else deepcopy(iir_params)
              )
              out.update(b=np.array([1.0]), a=np.array([1.0]))
          else:
              freq = [0, sfreq / 2.0]
              gain = [1.0, 1.0]
      if l_freq is None and h_freq is not None:
          h_freq = h_freq.item()
          logger.info(f"Setting up low-pass filter at {h_freq:0.2g} Hz")
          (
              data,
              sfreq,
              _,
              f_p,
              _,
              f_s,
              filter_length,
              phase,
              fir_window,
              fir_design,
          ) = _triage_filter_params(
              data,
              sfreq,
              None,
              h_freq,
              None,
              h_trans_bandwidth,
              filter_length,
              method,
              phase,
              fir_window,
              fir_design,
          )
          if method == "iir":
              out = construct_iir_filter(
                  iir_params, f_p, f_s, sfreq, "lowpass", phase=phase
              )
          else:  # 'fir'
              freq = [0, f_p, f_s]
              gain = [1, 1, 0]
              if f_s != sfreq / 2.0:
                  freq += [sfreq / 2.0]
                  gain += [0]
      elif l_freq is not None and h_freq is None:
          l_freq = l_freq.item()
          logger.info(
              f"Setting up high-pass filter at {l_freq:0.2g} Hz"
          )
          (
              data,
              sfreq,
              pass_,
              _,
              stop,
              _,
              filter_length,
              phase,
              fir_window,
              fir_design,
          ) = _triage_filter_params(
              data,
              sfreq,
              l_freq,
              None,
              l_trans_bandwidth,
              None,
              filter_length,
              method,
              phase,
              fir_window,
              fir_design,
          )
          if method == "iir":
              out = construct_iir_filter(
                  iir_params,
                  pass_,
                  stop,
                  sfreq,
                  "highpass",
                  phase=phase,
              )
          else:  # 'fir'
              freq = [stop, pass_, sfreq / 2.0]
              gain = [0, 1, 1]
              if stop != 0:
                  freq = [0] + freq
                  gain = [0] + gain
      elif l_freq is not None and h_freq is not None:
          if (l_freq < h_freq).any():
              l_freq, h_freq = l_freq.item(), h_freq.item()
              logger.info(
                  f"Setting up band-pass filter from {l_freq:0.2g} - {h_freq:0.2g} Hz"
              )
              (
                  data,
                  sfreq,
                  f_p1,
                  f_p2,
                  f_s1,
                  f_s2,
                  filter_length,
                  phase,
                  fir_window,
                  fir_design,
              ) = _triage_filter_params(
                  data,
                  sfreq,
                  l_freq,
                  h_freq,
                  l_trans_bandwidth,
                  h_trans_bandwidth,
                  filter_length,
                  method,
                  phase,
                  fir_window,
                  fir_design,
              )
              if method == "iir":
                  out = construct_iir_filter(
                      iir_params,
                      [f_p1, f_p2],
                      [f_s1, f_s2],
                      sfreq,
                      "bandpass",
                      phase=phase,
                  )
              else:  # 'fir'
                  freq = [f_s1, f_p1, f_p2, f_s2]
                  gain = [0, 1, 1, 0]
                  if f_s2 != sfreq / 2.0:
                      freq += [sfreq / 2.0]
                      gain += [0]
                  if f_s1 != 0:
                      freq = [0] + freq
                      gain = [0] + gain
          else:
              # This could possibly be removed after 0.14 release, but might
              # as well leave it in to sanity check notch_filter
              if len(l_freq) != len(h_freq):
                  raise ValueError(
                      "l_freq and h_freq must be the same length"
                  )
              msg = "Setting up band-stop filter"
              if len(l_freq) == 1:
                  l_freq, h_freq = l_freq.item(), h_freq.item()
                  msg += f" from {h_freq:0.2g} - {l_freq:0.2g} Hz"
              logger.info(msg)
              # Note: order of outputs is intentionally switched here!
              (
                  data,
                  sfreq,
                  f_s1,
                  f_s2,
                  f_p1,
                  f_p2,
                  filter_length,
                  phase,
                  fir_window,
                  fir_design,
              ) = _triage_filter_params(
                  data,
                  sfreq,
                  h_freq,
                  l_freq,
                  h_trans_bandwidth,
                  l_trans_bandwidth,
                  filter_length,
                  method,
                  phase,
                  fir_window,
                  fir_design,
                  bands="arr",
                  reverse=True,
              )
              if method == "iir":
                  if len(f_p1) != 1:
                      raise ValueError(
                          "Multiple stop-bands can only be used with method='fir' "
                          "and method='spectrum_fit'"
                      )
                  out = construct_iir_filter(
                      iir_params,
                      [f_p1[0], f_p2[0]],
                      [f_s1[0], f_s2[0]],
                      sfreq,
                      "bandstop",
                      phase=phase,
                  )
              else:  # 'fir'
                  freq = np.r_[f_p1, f_s1, f_s2, f_p2]
                  gain = np.r_[
                      np.ones_like(f_p1),
                      np.zeros_like(f_s1),
                      np.zeros_like(f_s2),
                      np.ones_like(f_p2),
                  ]
                  order = np.argsort(freq)
                  freq = freq[order]
                  gain = gain[order]
                  if freq[0] != 0:
                      freq = np.r_[[0.0], freq]
                      gain = np.r_[[1.0], gain]
                  if freq[-1] != sfreq / 2.0:
                      freq = np.r_[freq, [sfreq / 2.0]]
                      gain = np.r_[gain, [1.0]]
                  if np.any(np.abs(np.diff(gain, 2)) > 1):
                      raise ValueError(
                          "Stop bands are not sufficiently "
                          "separated."
                      )
      if method == "fir":
          out = _construct_fir_filter(
              sfreq,
              freq,
              gain,
              filter_length,
              phase,
              fir_window,
              fir_design,
          )
      return out
  
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 16 for calling a global function with example usage: create_filter(data, sfreq, l_freq, h_freq, filter_length, l_trans_bandwidth, h_trans_bandwidth, method, iir_params, phase, fir_window, fir_design, verbose) and returns: out