def validate_frames(frames: torch.Tensor | None) -> torch.Tensor | None:
        """Validate frames tensor.

        Args:
            frames (torch.Tensor | None): Input frames tensor or frame indices or ``None``.

        Returns:
            torch.Tensor | None: Validated frames tensor or ``None``.

        Raises:
            TypeError: If ``frames`` is not a ``torch.Tensor``.
            ValueError: If frames tensor is not a 1D tensor of indices.

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoValidator
            >>> indices = torch.tensor([0, 5, 10])
            >>> validated = VideoValidator.validate_frames(indices)
            >>> validated
            tensor([0, 5, 10])
        """
        if frames is None:
            return None
        if not isinstance(frames, torch.Tensor):
            msg = f"Frames must be a torch.Tensor, got {type(frames)}."
            raise TypeError(msg)

        # Ensure frames is a 1D tensor of indices
        if frames.ndim != 1 and frames.numel() != 1:
            msg = f"Frames must be a 1D tensor of indices or a single scalar tensor, got shape {frames.shape}."
            raise ValueError(msg)
        if frames.numel() == 1:
            frames = frames.view(1)
        # Ensure all indices are non-negative integers
        if not torch.all(frames >= 0) or not frames.dtype.is_floating_point:
            if not frames.dtype.is_floating_point:
                frames = frames.to(torch.int64)
            else:
                msg = "All frame indices must be non-negative integers."
                raise ValueError(msg)
        return frames
Validate frames tensor.

        Args:
            frames (torch.Tensor | None): Input frames tensor or frame indices or ``None``.

        Returns:
            torch.Tensor | None: Validated frames tensor or ``None``.

        Raises:
            TypeError: If ``frames`` is not a ``torch.Tensor``.
            ValueError: If frames tensor is not a 1D tensor of indices.

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoValidator
            >>> indices = torch.tensor([0, 5, 10])
            >>> validated = VideoValidator.validate_frames(indices)
            >>> validated
            tensor([0, 5, 10])
        
src/anomalib/data/validators/torch/video.py