def _get_window_embeddings(self, feature_map: torch.Tensor, masks: torch.Tensor) -> torch.Tensor:
        """Compute embeddings for each window in feature map using given masks.

        Args:
            feature_map (torch.Tensor): Input features of shape
                ``(n_batches, n_patches, dimensionality)``.
            masks (torch.Tensor): Window location masks of shape
                ``(kernel_size, n_masks)``.

        Returns:
            torch.Tensor: Embeddings for each sliding window location.
        """
        batch_size = feature_map.shape[0]
        n_masks = masks.shape[1]

        # prepend zero index for class embeddings
        class_index = torch.zeros(1, n_masks, dtype=int).to(feature_map.device)
        masks = torch.cat((class_index, masks + 1)).T  # +1 to account for class index
        # apply masks to feature map
        masked = torch.cat([torch.index_select(feature_map, 1, mask) for mask in masks])

        # finish forward pass on masked features
        masked = self.clip.visual.patch_dropout(masked)
        masked = self.clip.visual.ln_pre(masked)

        masked = masked.permute(1, 0, 2)  # NLD -> LND
        masked = self.clip.visual.transformer(masked)
        masked = masked.permute(1, 0, 2)  # LND -> NLD

        masked = self.clip.visual.ln_post(masked)
        pooled, _ = self.clip.visual._global_pool(masked)  # noqa: SLF001

        if self.clip.visual.proj is not None:
            pooled = pooled @ self.clip.visual.proj

        return pooled.reshape((n_masks, batch_size, -1)).permute(1, 0, 2)
Compute embeddings for each window in feature map using given masks.

        Args:
            feature_map (torch.Tensor): Input features of shape
                ``(n_batches, n_patches, dimensionality)``.
            masks (torch.Tensor): Window location masks of shape
                ``(kernel_size, n_masks)``.

        Returns:
            torch.Tensor: Embeddings for each sliding window location.
        
src/anomalib/models/image/winclip/torch_model.py