def predict(self, features: dict[FeatureType, torch.Tensor]) -> tuple[torch.Tensor, torch.Tensor]:
        """Predict region and image-level anomaly scores.

        Computes anomaly scores for each region in the frame and an overall frame
        score based on the maximum region score.

        Args:
            features (dict[FeatureType, torch.Tensor]): Dictionary containing
                extracted features for a single frame. Keys are feature types and
                values are the corresponding feature tensors.

        Returns:
            tuple[torch.Tensor, torch.Tensor]: A tuple containing:
                - Region-level anomaly scores for all regions within the frame
                - Frame-level anomaly score for the frame

        Example:
            >>> features = {
            ...     FeatureType.VELOCITY: velocity_features,
            ...     FeatureType.DEEP: deep_features,
            ...     FeatureType.POSE: pose_features
            ... }
            >>> region_scores, image_score = estimator.predict(features)
        """
        n_regions = next(iter(features.values())).shape[0]
        device = next(iter(features.values())).device
        region_scores = torch.zeros(n_regions).to(device)
        image_score = 0
        if self.use_velocity_features and features[FeatureType.VELOCITY].numel():
            velocity_scores = self.velocity_estimator.predict(features[FeatureType.VELOCITY])
            region_scores += velocity_scores
            image_score += velocity_scores.max()
        if self.use_deep_features and features[FeatureType.DEEP].numel():
            deep_scores = self.appearance_estimator.predict(features[FeatureType.DEEP])
            region_scores += deep_scores
            image_score += deep_scores.max()
        if self.use_pose_features and features[FeatureType.POSE].numel():
            pose_scores = self.pose_estimator.predict(features[FeatureType.POSE])
            region_scores += pose_scores
            image_score += pose_scores.max()
        return region_scores, image_score
Predict region and image-level anomaly scores.

        Computes anomaly scores for each region in the frame and an overall frame
        score based on the maximum region score.

        Args:
            features (dict[FeatureType, torch.Tensor]): Dictionary containing
                extracted features for a single frame. Keys are feature types and
                values are the corresponding feature tensors.

        Returns:
            tuple[torch.Tensor, torch.Tensor]: A tuple containing:
                - Region-level anomaly scores for all regions within the frame
                - Frame-level anomaly score for the frame

        Example:
            >>> features = {
            ...     FeatureType.VELOCITY: velocity_features,
            ...     FeatureType.DEEP: deep_features,
            ...     FeatureType.POSE: pose_features
            ... }
            >>> region_scores, image_score = estimator.predict(features)
        
src/anomalib/models/video/ai_vad/density.py