code: def istft(X, tstep=None, Tx=None):
      """ISTFT Inverse Short-Term Fourier Transform using a sine window.
  
      Parameters
      ----------
      X : array, shape (..., wsize / 2 + 1, n_step)
          The STFT coefficients for positive frequencies.
      tstep : int
          Step between successive windows in samples (must be a multiple of 2,
          a divider of wsize and smaller than wsize/2) (default: wsize/2).
      Tx : int
          Length of returned signal. If None Tx = n_step * tstep.
  
      Returns
      -------
      x : array, shape (Tx,)
          Array containing the inverse STFT signal.
  
      See Also
      --------
      stft
      """
      # Errors and warnings
      X = np.asarray(X)
      if X.ndim < 2:
          raise ValueError(f"X must have ndim >= 2, got {X.ndim}")
      n_win, n_step = X.shape[-2:]
      signal_shape = X.shape[:-2]
      if n_win % 2 == 0:
          raise ValueError(
              "The number of rows of the STFT matrix must be odd."
          )
  
      wsize = 2 * (n_win - 1)
      if tstep is None:
          tstep = wsize / 2
  
      if wsize % tstep:
          raise ValueError(
              "The step size must be a divider of two times the "
              "number of rows of the STFT matrix minus two."
          )
  
      if wsize % 2:
          raise ValueError("The step size must be a multiple of 2.")
  
      if tstep > wsize / 2:
          raise ValueError(
              "The step size must be smaller than the number of "
              "rows of the STFT matrix minus one."
          )
  
      if Tx is None:
          Tx = n_step * tstep
  
      T = n_step * tstep
  
      x = np.zeros(
          signal_shape + (T + wsize - tstep,), dtype=np.float64
      )
  
      if np.prod(signal_shape) == 0:
          return x[..., :Tx]
  
      # Defining sine window
      win = np.sin(np.arange(0.5, wsize + 0.5) / wsize * np.pi)
      # win = win / norm(win);
  
      # Pre-processing for edges
      swin = np.zeros(T + wsize - tstep, dtype=np.float64)
      for t in range(n_step):
          swin[t * tstep : t * tstep + wsize] += win**2
      swin = np.sqrt(swin / wsize)
  
      for t in range(n_step):
          # IFFT
          frame = irfft(X[..., t], wsize)
          # Overlap-add
          frame *= win / swin[t * tstep : t * tstep + wsize]
          x[..., t * tstep : t * tstep + wsize] += frame
  
      # Truncation
      x = x[..., (wsize - tstep) // 2 : (wsize - tstep) // 2 + T + 1]
      x = x[..., :Tx].copy()
      return x
  
file_path: mne-python/mne/time_frequency/_stft.py
imports: from math import ceil
  import numpy
  from scipy.fft import irfft, rfft, rfftfreq
  from ..utils import logger, verbose
label_desc: Use image node_id 2 for calling a global function with example usage: istft(X, tstep, Tx) and returns: x, x