class_docstr: STFT and iSTFT share the same `inverse_stft` function
class_docstr_tok: ["STFT","and","iSTFT","share","the","same","`","inverse_stft","`","function"]
code: def inverse_stft(
      self,
      X,
      kernel_cos,
      kernel_sin,
      onesided=True,
      length=None,
      refresh_win=True,
  ):
      # If the input spectrogram contains only half of the n_fft
      # Use extend_fbins function to get back another half
      if onesided:
          X = extend_fbins(X)  # extend freq
      X_real, X_imag = X[:, :, :, 0], X[:, :, :, 1]
  
      # broadcast dimensions to support 2D convolution
      X_real_bc = X_real.unsqueeze(1)
      X_imag_bc = X_imag.unsqueeze(1)
      a1 = conv2d(X_real_bc, kernel_cos, stride=(1, 1))
      b2 = conv2d(X_imag_bc, kernel_sin, stride=(1, 1))
      # compute real and imag part. signal lies in the real part
      real = a1 - b2
      real = real.squeeze(-2) * self.window_mask
  
      # Normalize the amplitude with n_fft
      real /= self.n_fft
  
      # Overlap and Add algorithm to connect all the frames
      real = overlap_add(real, self.stride)
  
      # Prepare the window sumsqure for division
      # Only need to create this window once to save time
      # Unless the input spectrograms have different time steps
      if hasattr(self, "w_sum") == False or refresh_win == True:
          self.w_sum = torch_window_sumsquare(
              self.window_mask.flatten(),
              X.shape[2],
              self.stride,
              self.n_fft,
          ).flatten()
          self.nonzero_indices = self.w_sum > 1e-10
      else:
          pass
      real[:, self.nonzero_indices] = real[:, self.nonzero_indices].div(
          self.w_sum[self.nonzero_indices]
      )
      # Remove padding
      if length is None:
          if self.center:
              real = real[:, self.pad_amount : -self.pad_amount]
  
      else:
          if self.center:
              real = real[:, self.pad_amount : self.pad_amount + length]
          else:
              real = real[:, :length]
  
      return real
  
file_path: nnAudio/Installation/nnAudio/features/stft.py
imports: from torch.nn.functional import conv1d, conv2d, fold
  import torch.nn
  import torch
  import numpy
  from time import time
  from ..utils import *
  from scipy.signal import get_window
label_desc: Use image node_id 1 for calling the STFTBase obj's underlying member method code with example usage: obj.inverse_stft(X, kernel_cos, kernel_sin, onesided, length, refresh_win) and returns: real