def create_pids2idxs(data_source):
    """Creates a mapping between pids and indexes of images for that pid.
    Returns:
        2D List with pids => idx
    """
    pid2imgs = {}
    for idx, (img, target, _) in enumerate(data_source.imgs):
        if target not in pid2imgs:
            pid2imgs[target] = [idx]
        else:
            pid2imgs[target].append(idx)
    return pid2imgs