def pascal_voc_palette(num_cls=None):
    """
    Generates the PASCAL Visual Object Classes (PASCAL VOC) data-set color palette.
    Data-Set URL:
    http://host.robots.ox.ac.uk/pascal/VOC/ .
    Original source taken from:
    https://gluon-cv.mxnet.io/_modules/gluoncv/utils/viz/segmentation.html .

    `num_cls`: the number of colors to generate
    return: the generated color palette
    """
    # by default generate 256 colors
    if num_cls is None:
        num_cls = 256

    palette = [0] * (num_cls * 3)
    for j in range(0, num_cls):
        lab = j
        palette[j*3+0] = 0
        palette[j*3+1] = 0
        palette[j*3+2] = 0
        i = 0
        while lab > 0:
            palette[j*3+0] |= (((lab >> 0) & 1) << (7-i))
            palette[j*3+1] |= (((lab >> 1) & 1) << (7-i))
            palette[j*3+2] |= (((lab >> 2) & 1) << (7-i))
            i = i + 1
            lab >>= 3
    return palette