def validate_depth_map(depth_map: torch.Tensor | None) -> torch.Tensor | None:
        """Validate the depth map for a batch.

        This method validates batches of depth maps. It handles:
            - Single-channel and RGB depth maps
            - Batch dimension validation
            - Type conversion to float32
            - None inputs

        Args:
            depth_map (``torch.Tensor`` | ``None``): Input depth map to validate.

        Returns:
            ``torch.Tensor`` | ``None``: Validated depth map as float32, or None.

        Raises:
            TypeError: If ``depth_map`` is not a torch.Tensor.
            ValueError: If ``depth_map`` shape is invalid or batch size mismatch.

        Example:
            >>> import torch
            >>> from anomalib.data.validators import DepthBatchValidator
            >>> depth_map = torch.rand(4, 224, 224)  # [N, H, W]
            >>> validated = DepthBatchValidator.validate_depth_map(depth_map)
            >>> print(validated.shape)
            torch.Size([4, 224, 224])
        """
        if depth_map is None:
            return None
        if not isinstance(depth_map, torch.Tensor):
            msg = f"Depth map must be a torch.Tensor, got {type(depth_map)}."
            raise TypeError(msg)
        if depth_map.ndim not in {3, 4}:
            msg = f"Depth map must have shape [N, H, W] or [N, C, H, W], got shape {depth_map.shape}."
            raise ValueError(msg)
        if depth_map.ndim == 4 and depth_map.shape[1] != 1 and depth_map.shape[1] != 3:
            msg = f"Depth map with 4 dimensions must have 1 or 3 channels, got {depth_map.shape[1]}."
            raise ValueError(msg)
        return depth_map.to(torch.float32)
Validate the depth map for a batch.

        This method validates batches of depth maps. It handles:
            - Single-channel and RGB depth maps
            - Batch dimension validation
            - Type conversion to float32
            - None inputs

        Args:
            depth_map (``torch.Tensor`` | ``None``): Input depth map to validate.

        Returns:
            ``torch.Tensor`` | ``None``: Validated depth map as float32, or None.

        Raises:
            TypeError: If ``depth_map`` is not a torch.Tensor.
            ValueError: If ``depth_map`` shape is invalid or batch size mismatch.

        Example:
            >>> import torch
            >>> from anomalib.data.validators import DepthBatchValidator
            >>> depth_map = torch.rand(4, 224, 224)  # [N, H, W]
            >>> validated = DepthBatchValidator.validate_depth_map(depth_map)
            >>> print(validated.shape)
            torch.Size([4, 224, 224])
        
src/anomalib/data/validators/torch/depth.py