<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _normalize_window(window, nfft, library, dtype):
 """Normalise a window specification for a PSD calculation Parameters window : `str`, `numpy.ndarray`, `None` the input window specification nfft : `int` the length of the Fourier transform, in samples library : `str` the name of the library that provides the PSD routine dtype : `type` the required type of the window array, only used if `library='lal'` is given Returns ------- window : `numpy.ndarray`, `lal.REAL8Window` a numpy-, or `LAL`-format window array """

    if library == '_lal' and isinstance(window, numpy.ndarray):
        from ._lal import window_from_array
        return window_from_array(window)
    if library == '_lal':
        from ._lal import generate_window
        return generate_window(nfft, window=window, dtype=dtype)
    if isinstance(window, string_types):
        window = canonical_name(window)
    if isinstance(window, string_types + (tuple,)):
        return get_window(window, nfft)
    return None