def validate_target_frame(target_frame: int | None) -> int | None:
        """Validate the target frame index.

        Args:
            target_frame (``int`` | ``None``): Input target frame index to validate.

        Returns:
            ``int`` | ``None``: Validated target frame index, or None if input is None.

        Raises:
            TypeError: If ``target_frame`` is not an integer.
            ValueError: If ``target_frame`` is negative.

        Example:
            >>> validator = NumpyVideoValidator()
            >>> frame = 5
            >>> validated_frame = validator.validate_target_frame(frame)
            >>> print(validated_frame)
            5
        """
        if target_frame is None:
            return None
        if not isinstance(target_frame, int):
            msg = f"Target frame must be an integer, got {type(target_frame)}."
            raise TypeError(msg)
        if target_frame < 0:
            msg = "Target frame index must be non-negative."
            raise ValueError(msg)
        return target_frame
Validate the target frame index.

        Args:
            target_frame (``int`` | ``None``): Input target frame index to validate.

        Returns:
            ``int`` | ``None``: Validated target frame index, or None if input is None.

        Raises:
            TypeError: If ``target_frame`` is not an integer.
            ValueError: If ``target_frame`` is negative.

        Example:
            >>> validator = NumpyVideoValidator()
            >>> frame = 5
            >>> validated_frame = validator.validate_target_frame(frame)
            >>> print(validated_frame)
            5
        
src/anomalib/data/validators/numpy/video.py