def generate_fft_plan(length, level=None, dtype='<STR_LIT>', forward=True):
from ...utils.lal import (find_typed_function, to_lal_type_str)<EOL>laltype = to_lal_type_str(dtype)<EOL>key = (length, bool(forward), laltype)<EOL>try:<EOL><INDENT>return LAL_FFTPLANS[key]<EOL><DEDENT>except KeyError:<EOL><INDENT>create = find_typed_function(dtype, '<STR_LIT>', '<STR_LIT>')<EOL>if level is None:<EOL><INDENT>level = LAL_FFTPLAN_LEVEL<EOL><DEDENT>LAL_FFTPLANS[key] = create(length, int(bool(forward)), level)<EOL>return LAL_FFTPLANS[key]<EOL><DEDENT>
Build a `REAL8FFTPlan` for a fast Fourier transform.

    Parameters
    ----------
    length : `int`
        number of samples to plan for in each FFT.

    level : `int`, optional
        amount of work to do when planning the FFT, default set by
        `LAL_FFTPLAN_LEVEL` module variable.

    dtype : :class:`numpy.dtype`, `type`, `str`, optional
        numeric type of data to plan for

    forward : bool, optional, default: `True`
        whether to create a forward or reverse FFT plan

    Returns
    -------
    plan : `REAL8FFTPlan` or similar
        FFT plan of the relevant data type