code: def conv1d_fft(f, g, dim=-1):
      N = f.size(dim)
      M = g.size(dim)
  
      fast_len = next_fast_len(N + M - 1)
  
      F_f = fft.rfft(f, fast_len, dim=dim)
      F_g = fft.rfft(g, fast_len, dim=dim)
  
      F_fg = F_f * F_g.conj()
      out = fft.irfft(F_fg, fast_len, dim=dim)
      out = out.roll((-1,), dims=(dim,))
      idx = torch.as_tensor(range(fast_len - N, fast_len)).to(
          out.device
      )
      out = out.index_select(dim, idx)
  
      return out
  
imports: import os
  import math
  import numpy
  from math import sqrt
  from scipy.fftpack import next_fast_len
label_desc: Use image node_id 1 for calling a global function with example usage: conv1d_fft(f, g, dim) and returns: out