def get_cxc_cap_similarities(cxc_dict, caption_objs, ind_caption=None):
    """
    Retrieve CxC similarities for given coco captions.
    If ind_caption is not None, retrieve similarities between it and 
    each caption_obj. Otherwise, retrieve pairwise similarities between
    caption_objs.
    """
 
    sims = []
    if ind_caption:
        cap_tuples = [(ind_caption,b) for b in caption_objs]
    else:
        cap_tuples = [(a,b) for a in caption_objs for b in caption_objs]

    for (capa, capb) in cap_tuples:
        idpair = (capa['id'], capb['id'])
        if idpair in cxc_dict:
            sims.append((capa, capb, cxc_dict[idpair]))
    return sims