"""Auto-generated stub for module: utils."""
from typing import Any, List, Tuple

# Functions
def accuracy(output: Any, target: Any, topk: tuple[int, ...] = (1,)) -> list[float]:
    """
    Compute top-k classification accuracy.
    
        Handles the edge case where *k* exceeds the number of classes by
        clamping to ``output.size(1)`` (from the r2plus1d BYOM repo).
    
        Args:
            output: Model logits with shape ``(N, C)``.
            target: Ground-truth class indices with shape ``(N,)``.
            topk: Tuple of *k* values to compute accuracy for.
    
        Returns:
            List of accuracy values (one per *k*), each in the **[0, 1]**
            range.
    """
    ...
def sanitise_metrics(metrics: list[dict[str, Any]]) -> list[dict[str, Any]]:
    """
    Clean metric values for JSON serialisation.
    
        Replaces ``inf`` / ``nan`` with ``0`` and rounds floats to
        *precision* decimal places.  This is the unified version of the
        ``round_metrics`` helper duplicated in the YOLOv10, D-FINE, and
        other BYOM codebases.
    
        Args:
            metrics: Raw epoch-metrics list — each entry is a dict with at
                least a ``metricValue`` key.
            precision: Number of decimal places to round to.
    
        Returns:
            A **new** list with sanitised numeric values (the original is
            not mutated).
    """
    ...

# Classes
class AverageMeter:
    # Running average tracker for a single scalar metric.
    #
    #     Commonly used to track loss and accuracy across mini-batches within
    #     an epoch.
    #
    #     Example::
    #
    #         losses = AverageMeter("Loss")
    #         for inputs, targets in loader:
    #             loss = criterion(model(inputs), targets)
    #             losses.update(loss.item(), n=inputs.size(0))
    #         print(losses)  # Loss 0.3420 (0.4567)
    #         print(losses.avg)  # 0.4567
    #
    #     Args:
    #         name: Human-readable label shown in ``__str__``.
    #         fmt: Format spec for ``val`` and ``avg`` (default ``":f"``).

    def __init__(self: Any, name: str = '', fmt: str = ':f') -> None:
        """
        Initialise the meter.
        
                Args:
                    name: Display name for :meth:`__str__`.
                    fmt: Float format spec (e.g. ``":.4f"``, ``":.2e"``).
        """
        ...

    def reset(self: Any) -> None:
        """
        Zero all accumulators.
        """
        ...

    def update(self: Any, val: float, n: int = 1) -> None:
        """
        Record *n* observations with value *val*.
        
                Args:
                    val: Per-sample (or per-batch-mean) value.
                    n: Number of observations this value represents
                        (typically ``batch_size``).
        """
        ...

