code: def ref_stft(
      x,
      window_size,
      stride,
      fft_size,
      window_type,
      center,
      pad_mode,
      as_istft_backward,
  ):
      if not as_istft_backward:
          # Use librosa.stft as the forward reference.
  
          # librosa.stft does not support batched input.
          window_type = (
              "hann" if window_type == "hanning" else window_type
          )
          window_type = (
              "boxcar" if window_type == "rectangular" else window_type
          )
          b = x.shape[0]
          ys = []
          for i in range(b):
              y = librosa.stft(
                  x[i],
                  n_fft=fft_size,
                  hop_length=stride,
                  win_length=window_size,
                  window=window_type,
                  center=center,
                  pad_mode=pad_mode,
              )
              ys.append(y)
  
          # Convert to nnabla stft output format
          ys = np.array(ys)
          y_r = ys.real
          y_i = ys.imag
  
          return y_r, y_i
      else:
          # Use F.istft backward as the reference
  
          x = nn.Variable.from_numpy_array(x)
  
          # Just create istft inputs
          y_r, y_i = F.stft(
              x,
              window_size,
              stride,
              fft_size,
              window_type,
              center,
              pad_mode,
          )
  
          # Execute istft backward
          y_r.need_grad = True
          y_i.need_grad = True
          y_r.grad.zero()
          y_i.grad.zero()
          z = F.istft(
              y_r,
              y_i,
              window_size,
              stride,
              fft_size,
              window_type,
              center,
              pad_mode,
          )
  
          z.forward()
          z.backward(x.data)
  
          return y_r.g, y_i.g
  
file_path: nnabla/python/test/function/test_stft.py
imports: import pytest
  import numpy
  import nnabla
  import nnabla.functions
  import librosa
  from nbla_test_utils import list_context
label_desc: Use image node_id 4 for calling a global function with example usage: ref_stft(x, window_size, stride, fft_size, window_type, center, pad_mode, as_istft_backward) and returns: y_r,  y_i, y_r,  y_i