code: def fft_conv1d(
      input: torch.Tensor,
      weight: torch.Tensor,
      bias: Optional[torch.Tensor] = None,
      stride: int = 1,
      padding: int = 0,
      block_ratio: float = 5,
  ):
      """
      Same as `torch.nn.functional.conv1d` but using FFT for the convolution.
      Please check PyTorch documentation for more information.
  
      Args:
          input (Tensor): input signal of shape `[B, C, T]`.
          weight (Tensor): weight of the convolution `[D, C, K]` with `D` the number
              of output channels.
          bias (Tensor or None): if not None, bias term for the convolution.
          stride (int): stride of convolution.
          padding (int): padding to apply to the input.
          block_ratio (float): can be tuned for speed. The input is splitted in chunks
              with a size of `int(block_ratio * kernel_size)`.
  
      Shape:
  
          - Inputs: `input` is `[B, C, T]`, `weight` is `[D, C, K]` and bias is `[D]`.
          - Output: `(*, T)`
  
  
      ..note::
          This function is faster than `torch.nn.functional.conv1d` only in specific cases.
          Typically, the kernel size should be of the order of 256 to see any real gain,
          for a stride of 1.
  
      ..Warning::
          Dilation and groups are not supported at the moment. This function might use
          more memory than the default Conv1d implementation.
      """
      input = F.pad(input, (padding, padding))
      batch, channels, length = input.shape
      out_channels, _, kernel_size = weight.shape
  
      if length < kernel_size:
          raise RuntimeError(
              f"Input should be at least as large as the kernel size {kernel_size}, "
              f"but it is only {length} samples long."
          )
      if block_ratio < 1:
          raise RuntimeError("Block ratio must be greater than 1.")
  
      # We are going to process the input blocks by blocks, as for some reason it is faster
      # and less memory intensive (I think the culprit is `torch.einsum`.
      block_size: int = min(int(kernel_size * block_ratio), length)
      fold_stride = block_size - kernel_size + 1
      weight = pad_to(weight, block_size)
      weight_z = _rfft(weight)
  
      # We pad the input and get the different frames, on which
      frames = unfold(input, block_size, fold_stride)
  
      frames_z = _rfft(frames)
      out_z = _compl_mul_conjugate(frames_z, weight_z)
      out = _irfft(out_z, block_size)
      # The last bit is invalid, because FFT will do a circular convolution.
      out = out[..., : -kernel_size + 1]
      out = out.reshape(batch, out_channels, -1)
      out = out[..., ::stride]
      target_length = (length - kernel_size) // stride + 1
      out = out[..., :target_length]
      if bias is not None:
          out += bias[:, None]
      return out
  
file_path: julius/julius/fftconv.py
imports: from typing import Optional
  import torch
  from torch.nn import functional
  from .core import pad_to, unfold
  from .utils import simple_repr
label_desc: Use image node_id 6 for calling a global function with example usage: fft_conv1d(input, weight, bias, stride, padding, block_ratio) and returns: out