def make_col2cls(labels):
    """
    Get a map <rgb tuple> -> (label code, label string), from the list of labels and rgb values.

    Example
    -------
    >>> make_col2cls([
    ...     {'label': 'label A', 'rgb': (125, 125, 0)},
    ...     {'label': 'label B', 'rgb': (255, 0, 0)}])
    {(125, 125, 0): (0, 'label A'),
       (255, 0, 0): (1, 'label B')}

    Parameters
    ----------
    labels: [{label:str, rgb:(r:int, g:int, b:int)}]

    Returns
    -------
    {(r:int, g:int, b:int) -> (code:int, label:str)}
    """
    return {tuple(lbl["rgb"]): (code, lbl["label"]) for code, lbl in enumerate(labels)}