def forward(self, batch: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor] | InferenceBatch:
        """Forward pass to get image and pixel anomaly scores.

        Args:
            batch (torch.Tensor): Input images of shape ``(batch_size, C, H, W)``.

        Returns:
            tuple[torch.Tensor, torch.Tensor] | InferenceBatch: Either tuple containing:
                - Image scores of shape ``(batch_size,)``
                - Pixel scores of shape ``(batch_size, H, W)``
                Or ``InferenceBatch`` with same information.
        """
        image_embeddings, window_embeddings, patch_embeddings = self.encode_image(batch)

        # get zero-shot scores
        image_scores = class_scores(image_embeddings, self.text_embeddings, self.temperature, target_class=1)
        multi_scale_scores = self._compute_zero_shot_scores(image_scores, window_embeddings)

        # get few-shot scores
        if self.k_shot:
            few_shot_scores = self._compute_few_shot_scores(patch_embeddings, window_embeddings)
            multi_scale_scores = (multi_scale_scores + few_shot_scores) / 2
            image_scores = (image_scores + few_shot_scores.amax(dim=(-2, -1))) / 2

        # reshape to image dimensions
        pixel_scores = nn.functional.interpolate(
            multi_scale_scores.unsqueeze(1),
            size=batch.shape[-2:],
            mode="bilinear",
        )
        return InferenceBatch(pred_score=image_scores, anomaly_map=pixel_scores.squeeze(1))
Forward pass to get image and pixel anomaly scores.

        Args:
            batch (torch.Tensor): Input images of shape ``(batch_size, C, H, W)``.

        Returns:
            tuple[torch.Tensor, torch.Tensor] | InferenceBatch: Either tuple containing:
                - Image scores of shape ``(batch_size,)``
                - Pixel scores of shape ``(batch_size, H, W)``
                Or ``InferenceBatch`` with same information.
        
src/anomalib/models/image/winclip/torch_model.py