src/transformers/models/vision_text_dual_encoder/modeling_tf_vision_text_dual_encoder.py/clip_loss
def clip_loss(similarity: tf.Tensor) -> tf.Tensor:
    caption_loss = contrastive_loss(similarity)
    image_loss = contrastive_loss(tf.transpose(similarity))
    return (caption_loss + image_loss) / 2.0