def collect_reference_images(self, dataloader: DataLoader) -> torch.Tensor:
        """Collect reference images for few-shot inference.

        Iterates through the training dataset until the required number of reference images
        (specified by ``k_shot``) are collected.

        Args:
            dataloader (DataLoader): DataLoader to collect reference images from

        Returns:
            torch.Tensor: Tensor containing the collected reference images
        """
        ref_images = torch.Tensor()
        for batch in dataloader:
            images = batch.image[: self.k_shot - ref_images.shape[0]]
            ref_images = torch.cat((ref_images, images))
            if self.k_shot == ref_images.shape[0]:
                break
        return ref_images
Collect reference images for few-shot inference.

        Iterates through the training dataset until the required number of reference images
        (specified by ``k_shot``) are collected.

        Args:
            dataloader (DataLoader): DataLoader to collect reference images from

        Returns:
            torch.Tensor: Tensor containing the collected reference images
        
src/anomalib/models/image/winclip/lightning_model.py