def validate_depth_map(depth_map: np.ndarray | None) -> np.ndarray | None:
        """Validate depth map array.

        Ensures the depth map has correct dimensions and data type.

        Args:
            depth_map (np.ndarray | None): Input depth map to validate.

        Returns:
            np.ndarray | None: Validated depth map as float32.

        Raises:
            TypeError: If depth map is not a numpy array.
            ValueError: If depth map dimensions are invalid.

        Example:
            >>> depth_map = np.random.rand(256, 256).astype(np.float32)
            >>> validated = NumpyDepthValidator.validate_depth_map(depth_map)
            >>> validated.shape
            (256, 256)
        """
        if depth_map is None:
            return None
        if not isinstance(depth_map, np.ndarray):
            msg = f"Depth map must be a numpy array, got {type(depth_map)}."
            raise TypeError(msg)
        if depth_map.ndim not in {2, 3}:
            msg = f"Depth map must have shape [H, W] or [H, W, 1], got shape {depth_map.shape}."
            raise ValueError(msg)
        if depth_map.ndim == 3 and depth_map.shape[2] != 1:
            msg = f"Depth map with 3 dimensions must have 1 channel, got {depth_map.shape[2]}."
            raise ValueError(msg)
        return depth_map.astype(np.float32)
Validate depth map array.

        Ensures the depth map has correct dimensions and data type.

        Args:
            depth_map (np.ndarray | None): Input depth map to validate.

        Returns:
            np.ndarray | None: Validated depth map as float32.

        Raises:
            TypeError: If depth map is not a numpy array.
            ValueError: If depth map dimensions are invalid.

        Example:
            >>> depth_map = np.random.rand(256, 256).astype(np.float32)
            >>> validated = NumpyDepthValidator.validate_depth_map(depth_map)
            >>> validated.shape
            (256, 256)
        
src/anomalib/data/validators/numpy/depth.py