def get_jaccard_similarities(captions, ind_caption=None):
    """
    Get jaccard similarities between different captions.
    If ind_caption is not None, similarities will be calculated between
    it and each of the given captions.
    Otherwise, calculate the pairwise similarities of the captions.
    """
    if ind_caption:
        caps1 = [ind_caption]
    else:
        caps1 = captions
    cap_pairs = [(a,b) for a in caps1 for b in captions]

    jaccs = []
    for (cap1, cap2) in cap_pairs:
        w1 = cap1["tokenized"]
        w2 = cap2["tokenized"]
        inter = [w for w in w1 if w in w2]
        union = w1.union(w2)
        jacc = len(inter) / len(union)
        jaccs.append((cap1, cap2, jacc))

    return jaccs