def validate_last_frame(last_frame: torch.Tensor | None) -> torch.Tensor | None:
        """Validate the last frame indices for a batch.

        Validates that the input last frame indices are non-negative integers.

        Args:
            last_frame (torch.Tensor | None): Input last frame indices. Should be a 1D
                tensor of non-negative numeric values.

        Returns:
            torch.Tensor | None: Validated last frame indices as int64 tensor.

        Raises:
            TypeError: If ``last_frame`` is not a ``torch.Tensor``.
            ValueError: If last frame indices are invalid.

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoBatchValidator
            >>> last_frames = torch.tensor([9.5, 12.2, 15.8, 10.0])
            >>> validated_last_frames = VideoBatchValidator.validate_last_frame(
            ...     last_frames
            ... )
            >>> print(validated_last_frames)
            tensor([ 9, 12, 15, 10])
        """
        if last_frame is None:
            return None
        if not isinstance(last_frame, torch.Tensor):
            msg = f"Last frame must be a torch.Tensor, got {type(last_frame)}."
            raise TypeError(msg)
        if last_frame.ndim != 1:
            msg = f"Last frame must be a 1D tensor, got shape {last_frame.shape}."
            raise ValueError(msg)
        last_frame = last_frame.int()
        if not torch.all(last_frame >= 0):
            msg = "Last frame indices must be non-negative."
            raise ValueError(msg)
        return last_frame
Validate the last frame indices for a batch.

        Validates that the input last frame indices are non-negative integers.

        Args:
            last_frame (torch.Tensor | None): Input last frame indices. Should be a 1D
                tensor of non-negative numeric values.

        Returns:
            torch.Tensor | None: Validated last frame indices as int64 tensor.

        Raises:
            TypeError: If ``last_frame`` is not a ``torch.Tensor``.
            ValueError: If last frame indices are invalid.

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoBatchValidator
            >>> last_frames = torch.tensor([9.5, 12.2, 15.8, 10.0])
            >>> validated_last_frames = VideoBatchValidator.validate_last_frame(
            ...     last_frames
            ... )
            >>> print(validated_last_frames)
            tensor([ 9, 12, 15, 10])
        
src/anomalib/data/validators/torch/video.py