def validate_target_frame(target_frame: np.ndarray | None) -> np.ndarray | None:
        """Validate the target frame indices for a batch.

        Args:
            target_frame (``np.ndarray`` | ``None``): Input target frame indices to
                validate.

        Returns:
            ``np.ndarray`` | ``None``: Validated target frame indices, or None if input is
                None.

        Raises:
            TypeError: If the input is not a numpy array of integers.
            ValueError: If the target frame indices are negative or the shape is invalid.

        Example:
            >>> import numpy as np
            >>> validator = NumpyVideoBatchValidator()
            >>> frames = np.array([0, 5, 2, 7])
            >>> validated_frames = validator.validate_target_frame(frames)
            >>> print(validated_frames, validated_frames.dtype)
            [0 5 2 7] int64
        """
        if target_frame is None:
            return None
        if not isinstance(target_frame, np.ndarray):
            msg = f"Target frame batch must be a numpy.ndarray, got {type(target_frame)}."
            raise TypeError(msg)
        if target_frame.ndim != 1:
            msg = f"Target frame batch must be 1-dimensional, got shape {target_frame.shape}."
            raise ValueError(msg)
        if not np.issubdtype(target_frame.dtype, np.integer):
            msg = f"Target frame batch must be integer type, got {target_frame.dtype}."
            raise TypeError(msg)
        if np.any(target_frame < 0):
            msg = "Target frame indices must be non-negative."
            raise ValueError(msg)
        return target_frame
Validate the target frame indices for a batch.

        Args:
            target_frame (``np.ndarray`` | ``None``): Input target frame indices to
                validate.

        Returns:
            ``np.ndarray`` | ``None``: Validated target frame indices, or None if input is
                None.

        Raises:
            TypeError: If the input is not a numpy array of integers.
            ValueError: If the target frame indices are negative or the shape is invalid.

        Example:
            >>> import numpy as np
            >>> validator = NumpyVideoBatchValidator()
            >>> frames = np.array([0, 5, 2, 7])
            >>> validated_frames = validator.validate_target_frame(frames)
            >>> print(validated_frames, validated_frames.dtype)
            [0 5 2 7] int64
        
src/anomalib/data/validators/numpy/video.py