def validate_image(image: np.ndarray) -> np.ndarray:
        """Validate the video array.

        Validates and normalizes input video arrays. Handles both RGB and grayscale
        videos, and ensures proper time dimension.

        Args:
            image (``np.ndarray``): Input video array to validate.

        Returns:
            ``np.ndarray``: Validated video array in format [T, H, W, C] as float32.

        Raises:
            TypeError: If ``image`` is not a numpy array.
            ValueError: If ``image`` dimensions or channels are invalid.

        Example:
            Validate RGB video::

                >>> import numpy as np
                >>> validator = NumpyVideoValidator()
                >>> video = np.random.rand(10, 224, 224, 3)  # [T, H, W, C]
                >>> validated_video = validator.validate_image(video)
                >>> print(validated_video.shape, validated_video.dtype)
                (10, 224, 224, 3) float32
        """
        if not isinstance(image, np.ndarray):
            msg = f"Video must be a numpy.ndarray, got {type(image)}."
            raise TypeError(msg)

        if image.ndim == 3:
            # Add time dimension for single frame
            image = np.expand_dims(image, axis=0)

        if image.ndim != 4:
            msg = f"Video must have 4 dimensions [T, H, W, C], got shape {image.shape}."
            raise ValueError(msg)

        if image.shape[3] not in {1, 3}:
            msg = f"Video must have 1 or 3 channels, got {image.shape[3]}."
            raise ValueError(msg)

        return image.astype(np.float32)
Validate the video array.

        Validates and normalizes input video arrays. Handles both RGB and grayscale
        videos, and ensures proper time dimension.

        Args:
            image (``np.ndarray``): Input video array to validate.

        Returns:
            ``np.ndarray``: Validated video array in format [T, H, W, C] as float32.

        Raises:
            TypeError: If ``image`` is not a numpy array.
            ValueError: If ``image`` dimensions or channels are invalid.

        Example:
            Validate RGB video::

                >>> import numpy as np
                >>> validator = NumpyVideoValidator()
                >>> video = np.random.rand(10, 224, 224, 3)  # [T, H, W, C]
                >>> validated_video = validator.validate_image(video)
                >>> print(validated_video.shape, validated_video.dtype)
                (10, 224, 224, 3) float32
        
src/anomalib/data/validators/numpy/video.py