code: def ref_grad_ifft(x, dy, signal_ndim, normalized, **kw):
      from nbla_test_utils import (
          convert_to_float2_array,
          convert_to_complex_array,
      )
  
      dy_complex = convert_to_complex_array(dy)
      batch_dims = dy_complex.shape[
          0 : len(dy_complex.shape) - signal_ndim
      ]
      ref_grad_complex = np.fft.fftn(
          dy_complex,
          axes=np.arange(signal_ndim) + len(batch_dims),
          norm="ortho" if normalized else None,
      )
      if not normalized:
          scale = (
              np.prod(ref_grad_complex.shape[len(batch_dims) :])
              if len(batch_dims) > 0
              else np.prod(ref_grad_complex.shape)
          )
          ref_grad_complex /= scale
      ref_grad = convert_to_float2_array(ref_grad_complex).astype(
          np.float32
      )
      return ref_grad.flatten()
  
file_path: nnabla/python/test/function/test_ifft.py
imports: import pytest
  import numpy
  import sys
  import nnabla.functions
  from nbla_test_utils import list_context
label_desc: Use image node_id 2 for calling a global function with example usage: ref_grad_ifft(x, dy, signal_ndim, normalized) and returns: ref_grad