"""Stub file for metrics directory."""
from typing import Any, List, Optional, Tuple

# Functions
# From classification
def accuracy_per_class(output: Any.Any, target: Any.Any) -> dict[int, float]:
    """
    Compute per-class one-vs-rest accuracy values.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Mapping of class id to one-vs-rest accuracy.
    """
    ...

# From classification
def calculate_metrics(output: Any.Any, target: Any.Any) -> tuple[Any.Any, Any.Any, Any.Any, Any.Any]:
    """
    Compute one-vs-rest TP/TN/FP/FN vectors for each class.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Tuple of tensors ``(tp, tn, fp, fn)`` for every class.
    """
    ...

# From classification
def confusion_matrix(output: Any.Any, target: Any.Any) -> Any.Any:
    """
    Return full multiclass confusion matrix with shape ``[C, C]``.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Confusion matrix tensor where rows are true labels and columns are predicted labels.
    """
    ...

# From classification
def confusion_matrix_per_class(output: Any.Any, target: Any.Any) -> dict[int, list[list[float]]]:
    """
    Return one-vs-rest confusion matrix for each class.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Mapping of class id to ``[[tp, fp], [fn, tn]]`` matrix.
    """
    ...

# From classification
def f1_score_per_class(output: Any.Any, target: Any.Any) -> dict[int, float]:
    """
    Compute per-class F1-score values.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Mapping of class id to F1-score.
    """
    ...

# From classification
def precision(output: Any.Any, target: Any.Any) -> dict[int, float]:
    """
    Compute per-class precision values.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Mapping of class id to precision.
    """
    ...

# From classification
def recall(output: Any.Any, target: Any.Any) -> dict[int, float]:
    """
    Compute per-class recall values.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Mapping of class id to recall.
    """
    ...

# From classification
def specificity(output: Any.Any, target: Any.Any) -> dict[int, float]:
    """
    Compute per-class specificity (true negative rate).
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Mapping of class id to specificity.
    """
    ...

# From classification
def specificity_all(output: Any.Any, target: Any.Any) -> float:
    """
    Compute overall specificity across all classes.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
    
        Returns:
            Overall specificity value.
    """
    ...

# From common
def accuracy(output: Any.Any, target: Any.Any, topk: Any[int] = (1,)) -> list[Any.Any]:
    """
    Compute top-k accuracy values for logits and labels.
    
        Args:
            output: Classification logits tensor with shape ``[N, C]``.
            target: Target label tensor with ``N`` elements.
            topk: Sequence of k-values for top-k accuracy calculation.
    
        Returns:
            List of scalar tensors in ``[0, 1]`` matching requested ``topk`` order.
    """
    ...

# From common
def calculate_metrics_for_all_classes(predictions: Any.Any, target: Any.Any) -> tuple[float, float, float]:
    """
    Compute macro precision, recall, and F1 from class indices.
    
        Args:
            predictions: Predicted class index tensor.
            target: Ground-truth class index tensor.
    
        Returns:
            Tuple ``(macro_precision, macro_recall, macro_f1)``.
    """
    ...

# From detection
def box_iou(boxes1: Any.Any, boxes2: Any.Any) -> Any.Any:
    """
    Compute IoU matrix for ``xyxy`` boxes.
    
        Args:
            boxes1: First box tensor with shape ``[N, 4]``.
            boxes2: Second box tensor with shape ``[M, 4]``.
    
        Returns:
            IoU matrix tensor with shape ``[N, M]``.
    """
    ...

# From detection
def compute_map_metrics(outputs: Any[Any[str, Any]], targets: Any[Any[str, Any]], num_classes: int, iou_thresholds: Any[float] = (0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95), background_class: int | None = 0) -> tuple[float, float, dict[int, float]]:
    """
    Compute ``mAP@50``, ``mAP@50-95``, and per-class ``AP@50``.
    
        Args:
            outputs: Iterable of model output dictionaries.
            targets: Iterable of target annotation dictionaries.
            num_classes: Total number of classes in evaluation.
            iou_thresholds: Sequence of IoU thresholds for mAP computation.
            background_class: Optional class id to exclude from evaluation.
    
        Returns:
            Tuple ``(map50, map50_95, per_class_ap_50)``.
    """
    ...

# From detection
def compute_metrics(outputs: Any[Any[str, Any]], targets: Any[Any[str, Any]], num_classes: int, iou_threshold: float = 0.5, background_class: int | None = 0) -> tuple[Any.Any, Any.Any, Any.Any]:
    """
    Compute per-class precision, recall, and F1-score for detections.
    
        Args:
            outputs: Iterable of model output dictionaries.
            targets: Iterable of target annotation dictionaries.
            num_classes: Total number of classes in evaluation.
            iou_threshold: IoU threshold used for matching.
            background_class: Optional class id to exclude from evaluation.
    
        Returns:
            Tuple of tensors ``(precision, recall, f1_score)`` per class.
    """
    ...

# From detection
def epoch_metrics(data_loader: Any[tuple[Any[Any.Any], Any[Any[str, Any]]]], model: Any.Any.Any, device: Any.Any, num_classes: int, iou_threshold: float = 0.5, background_class: int | None = 0) -> Any[str, float]:
    """
    Run model inference for one epoch and aggregate detection metrics.
    
        Args:
            data_loader: Iterable yielding ``(images, targets)`` mini-batches.
            model: Detection model used for inference.
            device: Device where inference should execute.
            num_classes: Total number of classes in evaluation.
            iou_threshold: IoU threshold used for matching in core metrics.
            background_class: Optional class id to exclude from evaluation.
    
        Returns:
            Mapping containing aggregate precision, recall, F1, and mAP metrics.
    """
    ...

from . import classification, common, detection