code: def fftconvolveinv(in1, in2, mode="full"):
      """
      Convolve two N-dimensional arrays using FFT. See convolve.
  
      copied from scipy.signal.signaltools, but here used to try out inverse
      filter. does not work or I cannot get it to work
  
      2010-10-23:
      looks ok to me for 1d,
      from results below with padded data array (fftp)
      but it does not work for multidimensional inverse filter (fftn)
      original signal.fftconvolve also uses fftn
      """
      s1 = np.array(in1.shape)
      s2 = np.array(in2.shape)
      complex_result = np.issubdtype(
          in1.dtype, np.complex
      ) or np.issubdtype(in2.dtype, np.complex)
      size = s1 + s2 - 1
  
      # Always use 2**n-sized FFT
      fsize = 2 ** np.ceil(np.log2(size))
      IN1 = fft.fftn(in1, fsize)
      # IN1 *= fftn(in2,fsize) #JP: this looks like the only change I made
      IN1 /= fft.fftn(in2, fsize)  # use inverse filter
      # note the inverse is elementwise not matrix inverse
      # is this correct, NO  does not seem to work for VARMA
      fslice = tuple([slice(0, int(sz)) for sz in size])
      ret = fft.ifftn(IN1)[fslice].copy()
      del IN1
      if not complex_result:
          ret = ret.real
      if mode == "full":
          return ret
      elif mode == "same":
          if np.product(s1, axis=0) > np.product(s2, axis=0):
              osize = s1
          else:
              osize = s2
          return trim_centered(ret, osize)
      elif mode == "valid":
          return trim_centered(ret, abs(s2 - s1) + 1)
  
file_path: statsmodels/statsmodels/tsa/filters/filtertools.py
imports: import numpy
  import scipy.fftpack
  from scipy import signal
  from statsmodels.tools.validation import array_like, PandasWrapper
label_desc: Use image node_id 2 for calling a global function with example usage: fftconvolveinv(in1, in2, mode) and returns: ret, trim_centered, trim_centered