def forward(self, batch: torch.Tensor, boxes: torch.Tensor, batch_size: int) -> torch.Tensor:
        """Extract deep features using CLIP encoder.

        Args:
            batch (torch.Tensor): Batch of RGB input images of shape ``(N, 3, H, W)``
            boxes (torch.Tensor): Bounding box coordinates of shape ``(M, 5)``. First
                column indicates batch index of the bbox, remaining columns are
                coordinates ``[x1, y1, x2, y2]``.
            batch_size (int): Number of images in the batch.

        Returns:
            torch.Tensor: Deep feature tensor of shape ``(M, 512)``, where ``M`` is
                the number of input regions and 512 is the CLIP feature dimension.
                Returns empty tensor if no valid regions.
        """
        rgb_regions = roi_align(batch, boxes, output_size=[224, 224])

        batched_regions = torch.split(rgb_regions, batch_size)
        batched_regions = [batch for batch in batched_regions if batch.numel() != 0]
        with torch.no_grad():
            features = [self.encoder.encode_image(self.transform(batch)) for batch in batched_regions]
            return torch.vstack(features).float() if len(features) else torch.empty(0, self.output_dim).to(batch.device)
Extract deep features using CLIP encoder.

        Args:
            batch (torch.Tensor): Batch of RGB input images of shape ``(N, 3, H, W)``
            boxes (torch.Tensor): Bounding box coordinates of shape ``(M, 5)``. First
                column indicates batch index of the bbox, remaining columns are
                coordinates ``[x1, y1, x2, y2]``.
            batch_size (int): Number of images in the batch.

        Returns:
            torch.Tensor: Deep feature tensor of shape ``(M, 512)``, where ``M`` is
                the number of input regions and 512 is the CLIP feature dimension.
                Returns empty tensor if no valid regions.
        
src/anomalib/models/video/ai_vad/features.py