code: def _fft(x_gpu, y_gpu, plan, direction, scale=None):
      """
      Fast Fourier Transform.
  
      Parameters
      ----------
      x_gpu : pycuda.gpuarray.GPUArray
          Input array.
      y_gpu : pycuda.gpuarray.GPUArray
          Output array.
      plan : Plan
          FFT plan.
      direction : { cufft.CUFFT_FORWARD, cufft.CUFFT_INVERSE }
          Transform direction. Only affects in-place transforms.
  
      Optional Parameters
      -------------------
      scale : int or float
          Scale the values in the output array by dividing them by this value.
  
      Notes
      -----
      This function should not be called directly.
      """
  
      if (x_gpu.gpudata == y_gpu.gpudata) and plan.fft_type not in [
          cufft.CUFFT_C2C,
          cufft.CUFFT_Z2Z,
      ]:
          raise ValueError(
              "can only compute in-place transform of complex data"
          )
  
      if (
          direction == cufft.CUFFT_FORWARD
          and plan.in_dtype in np.sctypes["complex"]
          and plan.out_dtype in np.sctypes["float"]
      ):
          raise ValueError(
              "cannot compute forward complex -> real transform"
          )
  
      if (
          direction == cufft.CUFFT_INVERSE
          and plan.in_dtype in np.sctypes["float"]
          and plan.out_dtype in np.sctypes["complex"]
      ):
          raise ValueError(
              "cannot compute inverse real -> complex transform"
          )
  
      if plan.fft_type in [cufft.CUFFT_C2C, cufft.CUFFT_Z2Z]:
          plan.fft_func(
              plan.handle,
              int(x_gpu.gpudata),
              int(y_gpu.gpudata),
              direction,
          )
      else:
          plan.fft_func(
              plan.handle, int(x_gpu.gpudata), int(y_gpu.gpudata)
          )
  
      # Scale the result by dividing it by the number of elements:
      if scale is not None:
          func = _get_scale_kernel(y_gpu.dtype)
          func(y_gpu.dtype.type(scale), y_gpu)
  
file_path: scikit-cuda/skcuda/fft.py
imports: import pycuda.driver
  import pycuda.gpuarray
  import pycuda.elementwise
  from pycuda.tools import context_dependent_memoize
  import pycuda.tools
  import numpy
  from .None import cufft
  from .cufft import CUFFT_COMPATIBILITY_NATIVE, CUFFT_COMPATIBILITY_FFTW_PADDING, CUFFT_COMPATIBILITY_FFTW_ASYMMETRIC, CUFFT_COMPATIBILITY_FFTW_ALL
  from .None import cudart
  from .None import misc
label_desc: Use image node_id 2 for calling a global function with example usage: _fft(x_gpu, y_gpu, plan, direction, scale) without return types