def batch_size(self) -> int:
        """Get the batch size.

        Returns:
            Number of items in batch

        Raises:
            AttributeError: If image attribute is not set
        """
        try:
            image = getattr(self, "image")  # noqa: B009
            return len(image)
        except (KeyError, AttributeError) as e:
            msg = "Cannot determine batch size because 'image' attribute not set."
            raise AttributeError(msg) from e
Get the batch size.

        Returns:
            Number of items in batch

        Raises:
            AttributeError: If image attribute is not set
        
src/anomalib/data/dataclasses/generic.py