def validate_image(image: torch.Tensor) -> torch.Tensor:
        """Validate a video tensor.

        Validates and normalizes video tensors, handling both single and multi-frame cases.
        Checks tensor type, dimensions, and channel count.

        Args:
            image (torch.Tensor): Input video tensor with shape either:
                - ``[C, H, W]`` for single frame
                - ``[T, C, H, W]`` for multiple frames
                where ``C`` is channels (1 or 3), ``H`` height, ``W`` width,
                and ``T`` number of frames.

        Returns:
            torch.Tensor: Validated and normalized video tensor.

        Raises:
            TypeError: If ``image`` is not a ``torch.Tensor``.
            ValueError: If tensor dimensions or channel count are invalid.

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoValidator
            >>> # Multi-frame RGB video
            >>> video = torch.rand(10, 3, 256, 256)
            >>> validated = VideoValidator.validate_image(video)
            >>> validated.shape
            torch.Size([10, 3, 256, 256])

            >>> # Single RGB frame
            >>> frame = torch.rand(3, 256, 256)
            >>> validated = VideoValidator.validate_image(frame)
            >>> validated.shape
            torch.Size([1, 3, 256, 256])

            >>> # Single grayscale frame
            >>> gray = torch.rand(1, 256, 256)
            >>> validated = VideoValidator.validate_image(gray)
            >>> validated.shape
            torch.Size([1, 1, 256, 256])
        """
        if not isinstance(image, torch.Tensor):
            msg = f"Video must be a torch.Tensor, got {type(image)}."
            raise TypeError(msg)

        if image.dim() == 3:  # Single frame case (C, H, W)
            if image.shape[0] not in {1, 3}:
                msg = f"Video must have 1 or 3 channels for single frame, got {image.shape[0]}."
                raise ValueError(msg)
        elif image.dim() == 4:  # Multiple frames case (T, C, H, W)
            if image.shape[1] not in {1, 3}:
                msg = f"Video must have 1 or 3 channels, got {image.shape[1]}."
                raise ValueError(msg)
        else:
            msg = f"Video must have 3 or 4 dimensions, got {image.dim()}."
            raise ValueError(msg)

        return to_dtype_image(image, torch.float32, scale=True)
Validate a video tensor.

        Validates and normalizes video tensors, handling both single and multi-frame cases.
        Checks tensor type, dimensions, and channel count.

        Args:
            image (torch.Tensor): Input video tensor with shape either:
                - ``[C, H, W]`` for single frame
                - ``[T, C, H, W]`` for multiple frames
                where ``C`` is channels (1 or 3), ``H`` height, ``W`` width,
                and ``T`` number of frames.

        Returns:
            torch.Tensor: Validated and normalized video tensor.

        Raises:
            TypeError: If ``image`` is not a ``torch.Tensor``.
            ValueError: If tensor dimensions or channel count are invalid.

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoValidator
            >>> # Multi-frame RGB video
            >>> video = torch.rand(10, 3, 256, 256)
            >>> validated = VideoValidator.validate_image(video)
            >>> validated.shape
            torch.Size([10, 3, 256, 256])

            >>> # Single RGB frame
            >>> frame = torch.rand(3, 256, 256)
            >>> validated = VideoValidator.validate_image(frame)
            >>> validated.shape
            torch.Size([1, 3, 256, 256])

            >>> # Single grayscale frame
            >>> gray = torch.rand(1, 256, 256)
            >>> validated = VideoValidator.validate_image(gray)
            >>> validated.shape
            torch.Size([1, 1, 256, 256])
        
src/anomalib/data/validators/torch/video.py