src/transformers/models/chinese_clip/modeling_chinese_clip.py/chinese_clip_loss
def chinese_clip_loss(similarity: torch.Tensor) -> torch.Tensor:
    caption_loss = contrastive_loss(similarity)
    image_loss = contrastive_loss(similarity.t())
    return (caption_loss + image_loss) / 2.0