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

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

        Args:
            target_frame (torch.Tensor | None): Input target frame indices. Should be a
                1D tensor of non-negative integers.

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

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

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoBatchValidator
            >>> target_frames = torch.tensor([5, 8, 3, 7])
            >>> validated_frames = VideoBatchValidator.validate_target_frame(target_frames)
            >>> print(validated_frames)
            tensor([5, 8, 3, 7])
        """
        if target_frame is None:
            return None
        if not isinstance(target_frame, torch.Tensor):
            msg = f"Target frame must be a torch.Tensor, got {type(target_frame)}."
            raise TypeError(msg)
        if target_frame.ndim != 1:
            msg = f"Target frame must be a 1D tensor, got shape {target_frame.shape}."
            raise ValueError(msg)
        if not torch.all(target_frame >= 0):
            msg = "Target frame indices must be non-negative."
            raise ValueError(msg)
        return target_frame.to(torch.int64)
Validate the target frame indices for a batch.

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

        Args:
            target_frame (torch.Tensor | None): Input target frame indices. Should be a
                1D tensor of non-negative integers.

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

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

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoBatchValidator
            >>> target_frames = torch.tensor([5, 8, 3, 7])
            >>> validated_frames = VideoBatchValidator.validate_target_frame(target_frames)
            >>> print(validated_frames)
            tensor([5, 8, 3, 7])
        
src/anomalib/data/validators/torch/video.py