code: def ref_istft(
      y_r,
      y_i,
      window_size,
      stride,
      fft_size,
      window_type,
      center,
      pad_mode,
      as_stft_backward,
  ):
      if not as_stft_backward:
          # Use librosa.istft as the forward reference.
  
          # Convert to librosa.istft input format.
          y = y_r + 1j * y_i
  
          # Get original signal length.
          x_shape = create_stft_input_shape(window_size)
          length = x_shape[1]
  
          # librosa.istft does not support batched input.
          window_type = (
              "hann" if window_type == "hanning" else window_type
          )
          b = y.shape[0]
          xs = []
          for i in range(b):
              x = librosa.istft(
                  y[i],
                  hop_length=stride,
                  win_length=window_size,
                  window=window_type,
                  center=center,
                  length=length,
              )
              xs.append(x)
          return np.array(xs)
      else:
          # Use F.stft backward as the reference
  
          y_r = nn.Variable.from_numpy_array(y_r)
          y_i = nn.Variable.from_numpy_array(y_i)
  
          # Just create stft inputs
          x = F.istft(
              y_r,
              y_i,
              window_size,
              stride,
              fft_size,
              window_type,
              center,
              pad_mode,
              True,
          )
  
          # Execute istft backward
          x.need_grad = True
          x.grad.zero()
          z_r, z_i = F.stft(
              x,
              window_size,
              stride,
              fft_size,
              window_type,
              center,
              pad_mode,
          )
  
          z_r.g = y_r.d
          z_i.g = y_i.d
          z = F.sink(z_r, z_i, one_input_grad=False)
          z.forward()
          z.backward()
  
          return x.g
  
file_path: nnabla/python/test/function/test_istft.py
imports: from operator import is_
  import pytest
  import numpy
  import nnabla
  import nnabla.functions
  import scipy.signal
  import librosa
  from nbla_test_utils import list_context
  from test_stft import create_stft_input_shape, create_window_func, is_nola_violation, ref_stft
label_desc: Use image node_id 1 for calling a global function with example usage: ref_istft(y_r, y_i, window_size, stride, fft_size, window_type, center, pad_mode, as_stft_backward) and returns: np, x