examples/research_projects/vqgan-clip/VQGAN_CLIP.py/VQGAN_CLIP/_get_clip_loss
class VQGAN_CLIP:    def _get_clip_loss(self, pos_prompts, neg_prompts, image):
        pos_logits = self._get_clip_similarity(pos_prompts["prompts"], image, weights=(1 / pos_prompts["weights"]))
        if neg_prompts:
            neg_logits = self._get_clip_similarity(neg_prompts["prompts"], image, weights=neg_prompts["weights"])
        else:
            neg_logits = torch.tensor([1], device=self.device)
        loss = -torch.log(pos_logits) + torch.log(neg_logits)
        return loss