import torch


def apply_background(I, background):
    """
    Applies a background RGB image to the input image I.

    Parameters
    ----------
    I : Tensor
        an image tensor in RGBDA format
    background : Tensor
        an image tensor in RGB format

    Returns
    -------
    Tensor
        an image tensor in RGBDA format
    """

    return torch.cat((I[0:3, :, :]+background*I[4, :, :], I[(3, 4), :, :]), dim=0)