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

from .io_utils import temporary_file_from_bytes
from .schemas import ActionPrediction, ClassificationPrediction, DetectionPrediction, FramewiseActionPredictions
from .schemas import DetectionPrediction

# Constants
FramewiseActionPredictions: Any = ...  # From schemas

# Functions
# From io_utils
def download_remote_file(url: str) -> str:
    """
    Download a remote artifact into a temporary file and return its local path.
    
        The file is intentionally not auto-deleted because model runtimes can keep
        lazy references to checkpoint files after constructor return.
    
        Args:
            url: Remote URL for the artifact to download.
            suffix: Suffix used when creating temporary file name.
            timeout_seconds: Per-request timeout passed to ``requests.get``.
            retries: Number of retry attempts after the initial try.
    
        Returns:
            Local filesystem path to the downloaded temporary file.
    """
    ...

# From io_utils
def is_remote_path(path: str) -> bool:
    """
    Return whether a path points to an HTTP(S) resource.
    
        Args:
            path: Input path or URL string to inspect.
    
        Returns:
            ``True`` when the scheme is HTTP or HTTPS, otherwise ``False``.
    """
    ...

# From io_utils
def prepare_torch_model_for_inference(model: Any.Any.Any, device: Any.Any | None = None) -> Any.Any.Any:
    """
    Move a torch model to target device and switch to eval mode.
    
        Args:
            model: Torch module to prepare for inference.
            device: Optional explicit target device.
    
        Returns:
            Inference-ready model moved to the resolved device.
    """
    ...

# From io_utils
def resolve_torch_device() -> Any.Any:
    """
    Resolve best available torch device for inference.
    
        Args:
            None.
    
        Returns:
            ``torch.device("cuda")`` when CUDA is available, else CPU device.
    """
    ...

# From io_utils
def temporary_file_from_bytes(data: Any) -> Any[str, None, None]:
    """
    Write bytes to a temporary file and clean it up on exit.
    
        Args:
            data: Raw bytes to write into the temporary file.
            suffix: Filename suffix used for the temporary file.
    
        Returns:
            Context manager yielding the temporary file path.
    """
    ...

# From model_loader
def report_model_load_failure(action_tracker: Any) -> None:
    """
    Report model-load failure without raising secondary tracker exceptions.
    
        Args:
            action_tracker: Tracker-like object for status/error reporting.
            error: Original model-load exception.
            status_code: Status code used for tracker update.
            location: Logical location string used for error logging.
            status_message: Human-readable status message.
            log_prefix: Prefix used for tracker error message formatting.
    
        Returns:
            None.
    """
    ...

# From postprocessor
def classification_top1_from_raw_output(raw_output: Any) -> Any:
    """
    Normalize common runtime outputs and return top-1 prediction.
    
        Args:
            raw_output: Runtime-specific raw model output object.
            confidence_digits: Number of decimal places for confidence rounding.
    
        Returns:
            Classification prediction dictionary with category and confidence.
    """
    ...

# From postprocessor
def classification_top1_prediction(logits: Any.Any) -> Any:
    """
    Return top-1 class prediction with confidence from logits.
    
        Args:
            logits: Model logits tensor with shape ``[N, C]``.
            confidence_digits: Number of decimal places for confidence rounding.
    
        Returns:
            Classification prediction dictionary with category and confidence.
    """
    ...

# From postprocessor
def format_detection_from_normalized_tensors(labels: Any.Any, boxes_xyxy_normalized: Any.Any, scores: Any.Any) -> list[Any]:
    """
    Convert normalized detection tensors into API-ready records.
    
        Args:
            labels: Tensor of class ids for detections.
            boxes_xyxy_normalized: Normalized ``[N, 4]`` boxes in ``xyxy`` format.
            scores: Confidence tensor aligned with boxes.
            image_width: Source image width in pixels.
            image_height: Source image height in pixels.
            confidence_threshold: Minimum confidence required to keep a detection.
    
        Returns:
            List of detection prediction dictionaries.
    """
    ...

# From postprocessor
def framewise_action_results(inference_results: Any[Any[str, Any]]) -> Any:
    """
    Group frame-level action predictions keyed by frame index string.
    
        Args:
            inference_results: Iterable of per-event action inference records.
            fps: Frames-per-second used to convert timestamps to frame indices.
            confidence_digits: Number of decimal places for confidence rounding.
    
        Returns:
            Mapping of frame index string to action prediction list.
    """
    ...

# From preprocessor
def build_image_transform(config: Any) -> Any.Any:
    """
    Construct torchvision transform pipeline for model inference.
    
        Args:
            config: Preprocessing configuration containing size and normalization.
    
        Returns:
            Composed torchvision transform callable.
    """
    ...

# From preprocessor
def get_model_device(model: Any.Any.Any) -> Any.Any:
    """
    Return model parameter device, or CPU for parameter-less models.
    
        Args:
            model: Torch module whose parameter device should be inspected.
    
        Returns:
            Device of first parameter, or CPU if module has no parameters.
    """
    ...

# From preprocessor
def load_rgb_image_from_bytes(image_bytes: Any) -> Any.Any:
    """
    Decode image bytes into an RGB PIL image.
    
        Args:
            image_bytes: Raw encoded image bytes.
    
        Returns:
            Decoded RGB ``PIL.Image`` object.
    """
    ...

# From preprocessor
def preprocess_image_from_bytes(image_bytes: Any) -> tuple[Any.Any, Any.Any]:
    """
    Decode and transform image bytes into batched tensor ``[1, C, H, W]``.
    
        Args:
            image_bytes: Raw encoded image bytes.
            config: Preprocessing configuration for resize and normalization.
            device: Optional device to move the output tensor to.
    
        Returns:
            Tuple of ``(image_tensor, pil_image)``.
    """
    ...

# From preprocessor
def probe_video_fps(video_bytes: Any) -> float:
    """
    Extract FPS from video bytes using OpenCV with temp-file isolation.
    
        Args:
            video_bytes: Raw encoded video bytes.
            default_fps: Fallback FPS value when probing fails.
    
        Returns:
            Probed FPS value, or ``default_fps`` when unavailable.
    """
    ...

# From status_handler
def safe_log_error(action_tracker: Any, file_path: str, location: str, message: str) -> None:
    """
    Log prediction errors without propagating tracker exceptions.
    
        Args:
            action_tracker: Tracker-like object implementing ``log_error``.
            file_path: Source file associated with the error.
            location: Logical module or location string.
            message: Error details to persist.
    
        Returns:
            None.
    """
    ...

# From status_handler
def safe_update_status(action_tracker: Any, step_code: str, status: str, description: str) -> None:
    """
    Submit status updates without propagating tracker exceptions.
    
        Args:
            action_tracker: Tracker-like object implementing ``update_status``.
            step_code: Prediction lifecycle step identifier.
            status: Status level such as ``OK`` or ``ERROR``.
            description: Human-readable status description.
    
        Returns:
            None.
    """
    ...

# From tensorrt_adapter
def adapt_tensorrt_yolo_output(output: Any) -> list[Any]:
    """
    Normalize YOLO detections from TensorRT/trtexec/Ultralytics outputs.
    
        Supported styles:
        - Ultralytics results list (result.boxes.xyxy/conf/cls)
        - TensorRT NMS plugin output (`num_dets`, `boxes`, `scores`, `classes`)
        - Dense detection matrix shaped [N, 6+] with `[x1,y1,x2,y2,score,cls,...]`
        - Raw head-like matrix [N, 5 + num_classes] or [N, 4 + num_classes]
    
        Args:
            output: Runtime-specific detection output object.
            image_width: Source image width in pixels.
            image_height: Source image height in pixels.
            config: Optional adapter configuration overrides.
    
        Returns:
            List of normalized detection prediction dictionaries.
    """
    ...

# Classes
# From preprocessor
class ImagePreprocessConfig:
    # Standard image preprocessing configuration.

    ...

# From schemas
class ActionPrediction:
    # Per-frame action prediction for video recognition.

    ...

# From schemas
class BoundingBox:
    # Axis-aligned bounding box in absolute pixel coordinates.

    ...

# From schemas
class ClassificationPrediction:
    # Single-label classification prediction.

    ...

# From schemas
class DetectionPrediction:
    # Object detection prediction record.

    ...

# From status_handler
class PredictionStatusCodes:
    # Canonical prediction-related status step codes.

    ...

# From status_handler
class PredictionStatusReporter:
    # Semantic status reporter for prediction error transitions.

    def __init__(self: Any, action_tracker: Any, codes: Any | None = None) -> None:
        """
        Create a reporter backed by an ActionTracker-like object.
        
                Args:
                    action_tracker: Tracker-like object used for status updates.
                    codes: Optional status code overrides.
        
                Returns:
                    None.
        """
        ...

    def model_load_failed(self: Any, msg: str = 'Error in loading model') -> None:
        """
        Emit model-load failure status.
        
                Args:
                    msg: Optional status description override.
        
                Returns:
                    None.
        """
        ...

    def prediction_failed(self: Any, msg: str = 'Error during prediction') -> None:
        """
        Emit prediction failure status.
        
                Args:
                    msg: Optional status description override.
        
                Returns:
                    None.
        """
        ...


# From tensorrt_adapter
class TensorRTYOLOAdapterConfig:
    # Configuration for adapting TensorRT YOLO detections.

    ...

from . import io_utils, model_loader, postprocessor, preprocessor, schemas, status_handler, tensorrt_adapter