code: def generate_fft_plan(length, level=None, dtype='float64', forward=True):
      
      from ...utils.lal import (find_typed_function, to_lal_type_str)
  
      # generate key for caching plan
      laltype = to_lal_type_str(dtype)
      key = (length, bool(forward), laltype)
  
      # find existing plan
      try:
          return LAL_FFTPLANS[key]
      # or create one
      except KeyError:
          create = find_typed_function(dtype, 'Create', 'FFTPlan')
          if level is None:
              level = LAL_FFTPLAN_LEVEL
          LAL_FFTPLANS[key] = create(length, int(bool(forward)), level)
          return LAL_FFTPLANS[key]
docs: 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