human
Complete this python program:
def fft_wrap(fft_func, kind=None, dtype=None):
assistant
#Here is the Python program you requested.

    """Wrap 1D complex FFT functions
    Takes a function that behaves like ``numpy.fft`` functions and
    a specified kind to match it to that are named after the functions
    in the ``numpy.fft`` API.
    Supported kinds include:
    * fft
    * ifft
    * rfft
    * irfft
    * hfft
    * ihfft
    Examples
    >>> parallel_fft = fft_wrap(np.fft.fft)
    >>> parallel_ifft = fft_wrap(np.fft.ifft)
    """
    if (scipy is not None):
        if (fft_func is scipy.fftpack.rfft):
            raise ValueError("SciPy's    `rfft`    doesn't    match    the    NumPy    API.")
        elif (fft_func is scipy.fftpack.irfft):
            raise ValueError("SciPy's    `irfft`    doesn't    match    the    NumPy    API.")
    if (kind is None):
        kind = fft_func.__name__
    try:
        out_chunk_fn = _out_chunk_fns[kind.rstrip('2n')]
    except KeyError:
        raise ValueError(('Given    unknown    `kind`    %s.' % kind))
    def func(a, s=None, axes=None):
        if (axes is None):
            if kind.endswith('2'):
                axes = ((-2), (-1))
            elif kind.endswith('n'):
                if (s is None):
                    axes = tuple(range(a.ndim))
                else:
                    axes = tuple(range(len(s)))
            else:
                axes = ((-1),)
        elif (len(set(axes)) < len(axes)):
            raise ValueError('Duplicate    axes    not    allowed.')
        _dtype = dtype
        if (_dtype is None):
            _dtype = fft_func(np.ones((len(axes) * (8,)), dtype=a.dtype)).dtype
        for each_axis in axes:
            if (len(a.chunks[each_axis]) != 1):
                raise ValueError((chunk_error % (each_axis, a.chunks[each_axis])))
        chunks = out_chunk_fn(a, s, axes)
        args = (s, axes)
        if kind.endswith('fft'):
            axis = (None if (axes is None) else axes[0])
            n = (None if (s is None) else s[0])
            args = (n, axis)
        return a.map_blocks(fft_func, dtype=_dtype, chunks=chunks, *args)
    if kind.endswith('fft'):
        _func = func
        def func(a, n=None, axis=None):
            s = None
            if (n is not None):
                s = (n,)
            axes = None
            if (axis is not None):
                axes = (axis,)
            return _func(a, s, axes)
    func_mod = inspect.getmodule(fft_func)
    func_name = fft_func.__name__
    func_fullname = ((func_mod.__name__ + '.') + func_name)
   ...