def calculate_lensing_template(bb_lensed, bb_unlensed):
    """Function to calculate the BB spectrum of lensing from output CLASS
    BB spectra.

    These spectra are the lened and unlensed outputs for a given
    set of cosmological parameters, therefore we simply take the difference
    of the lensed and unlensed BB spectrum. Note that this requires CLASS
    to have been run for l_max >= 2500 in order to achieve reliable accuracy.

    Parameters
    ----------
    bb_lensed: array_like
        BB spectrum containing both primordial and lensing contributions
        for a given run of CLASS.
    bb_unlensed: array_like
        BB spectrum containing only the primordial contribution to the BB
        spectrum.

    Returns
    -------
    array_like
        Template for the lensing spectrum (A_L=1).
    """
    return bb_lensed - bb_unlensed