code: def _mk_butter_filter(freq, type, order):
      """
      Args:
          freq: The cutoff frequency for highpass and lowpass filters. For
              band filters, a list of [low_cutoff, high_cutoff]
          type: "lowpass", "highpass", or "band"
          order: nth order butterworth filter (default: 5th order). The
              attenuation is -6dB/octave beyond the cutoff frequency (for 1st
              order). A Higher order filter will have more attenuation, each level
              adding an additional -6dB (so a 3rd order butterworth filter would
              be -18dB/octave).
  
      Returns:
          function which can filter a mono audio segment
  
      """
  
      def filter_fn(seg):
          assert seg.channels == 1
  
          nyq = 0.5 * seg.frame_rate
          try:
              freqs = [f / nyq for f in freq]
          except TypeError:
              freqs = freq / nyq
  
          sos = butter(order, freqs, btype=type, output="sos")
          y = sosfilt(sos, seg.get_array_of_samples())
  
          return seg._spawn(y.astype(seg.array_type))
  
      return filter_fn
  
imports: from scipy.signal import butter, sosfilt
  from .utils import register_pydub_effect, stereo_to_ms, ms_to_stereo
label_desc: Use image node_id 1 for calling a global function with example usage: _mk_butter_filter(freq, type, order) and returns: filter_fn, seg