class_docstr: adapted from Prem Seetharaman's https://github.com/pseeth/pytorch-stft
class_docstr_tok: ["adapted","from","Prem","Seetharaman","'s","https",":","\/\/github.com\/pseeth\/pytorch-stft"]
code: def __init__(
      self,
      filter_length=800,
      hop_length=200,
      win_length=800,
      window="hann",
  ):
      super(STFT, self).__init__()
      self.filter_length = filter_length
      self.hop_length = hop_length
      self.win_length = win_length
      self.window = window
      self.forward_transform = None
      scale = self.filter_length / self.hop_length
      fourier_basis = np.fft.fft(np.eye(self.filter_length))
  
      cutoff = int((self.filter_length / 2 + 1))
      fourier_basis = np.vstack(
          [
              np.real(fourier_basis[:cutoff, :]),
              np.imag(fourier_basis[:cutoff, :]),
          ]
      )
  
      forward_basis = torch.FloatTensor(fourier_basis[:, None, :])
      inverse_basis = torch.FloatTensor(
          np.linalg.pinv(scale * fourier_basis).T[:, None, :]
      )
  
      if window is not None:
          assert filter_length >= win_length
          # get window and zero center pad it to filter_length
          fft_window = get_window(window, win_length, fftbins=True)
          fft_window = pad_center(fft_window, filter_length)
          fft_window = torch.from_numpy(fft_window).float()
  
          # window the bases
          forward_basis *= fft_window
          inverse_basis *= fft_window
  
      self.register_buffer("forward_basis", forward_basis.float())
      self.register_buffer("inverse_basis", inverse_basis.float())
  
file_path: fairseq/examples/textless_nlp/gslm/unit2speech/tacotron2/stft.py
imports: import torch
  import numpy
  import torch.nn.functional
  from torch.autograd import Variable
  from scipy.signal import get_window
  from librosa.util import pad_center, tiny
  from .audio_processing import window_sumsquare
label_desc: Use image node_id 1 to create a new STFT object from inherited base classes: torch.nn with example: obj = STFT(filter_length, hop_length, win_length, window)