def validate_last_frame(last_frame: torch.Tensor | int | float | None) -> torch.Tensor | int | None:
        """Validate last frame index.

        Args:
            last_frame (torch.Tensor | int | float | None): Input last frame index or
                ``None``.

        Returns:
            torch.Tensor | int | None: Validated last frame index or ``None``.

        Raises:
            TypeError: If ``last_frame`` is not a tensor, int, or float.
            ValueError: If last frame index is negative.

        Examples:
            >>> from anomalib.data.validators import VideoValidator
            >>> # Integer input
            >>> validated = VideoValidator.validate_last_frame(5)
            >>> print(validated)
            5

            >>> # Float input
            >>> validated = VideoValidator.validate_last_frame(5.7)
            >>> print(validated)
            5

            >>> # Tensor input
            >>> import torch
            >>> tensor_frame = torch.tensor(10.3)
            >>> validated = VideoValidator.validate_last_frame(tensor_frame)
            >>> print(validated)
            tensor(10)
        """
        if last_frame is None:
            return None
        if isinstance(last_frame, int | float):
            last_frame = int(last_frame)
            if last_frame < 0:
                msg = f"Last frame index must be non-negative, got {last_frame}."
                raise ValueError(msg)
            return last_frame
        if isinstance(last_frame, torch.Tensor):
            if last_frame.numel() != 1:
                msg = f"Last frame must be a scalar tensor, got shape {last_frame.shape}."
                raise ValueError(msg)
            last_frame = last_frame.int()
            if last_frame.item() < 0:
                msg = f"Last frame index must be non-negative, got {last_frame.item()}."
                raise ValueError(msg)
            return last_frame
        msg = f"Last frame must be an int, float, or a torch.Tensor, got {type(last_frame)}."
        raise TypeError(msg)
Validate last frame index.

        Args:
            last_frame (torch.Tensor | int | float | None): Input last frame index or
                ``None``.

        Returns:
            torch.Tensor | int | None: Validated last frame index or ``None``.

        Raises:
            TypeError: If ``last_frame`` is not a tensor, int, or float.
            ValueError: If last frame index is negative.

        Examples:
            >>> from anomalib.data.validators import VideoValidator
            >>> # Integer input
            >>> validated = VideoValidator.validate_last_frame(5)
            >>> print(validated)
            5

            >>> # Float input
            >>> validated = VideoValidator.validate_last_frame(5.7)
            >>> print(validated)
            5

            >>> # Tensor input
            >>> import torch
            >>> tensor_frame = torch.tensor(10.3)
            >>> validated = VideoValidator.validate_last_frame(tensor_frame)
            >>> print(validated)
            tensor(10)
        
src/anomalib/data/validators/torch/video.py