Something like:
def create_mask(black, green, red):
    
    black[black == 1] = 1
    green[green == 1] = 2
    red[red == 1] = 3
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    mask = black + green + red
    return mask

Note that if I remember well, the CrossEntropyLoss expected classes that starts with index 0 so be carefull on which value you give to it.