def forward(self, **kwargs: dict[str, torch.Tensor]) -> torch.Tensor:
        """Generate anomaly map from teacher and student features.

        Expects the following keys in ``kwargs``:
        - ``teacher_features``: Dictionary of teacher network features
        - ``student_features``: Dictionary of student network features
        - ``image_size``: Target size for the anomaly map

        Args:
            kwargs (dict[str, torch.Tensor]): Keyword arguments containing
                required inputs

        Example:
            >>> generator = AnomalyMapGenerator()
            >>> anomaly_map = generator(
            ...     teacher_features=teacher_features,
            ...     student_features=student_features,
            ...     image_size=(256, 256)
            ... )

        Raises:
            ValueError: If required keys are missing from ``kwargs``

        Returns:
            torch.Tensor: Anomaly map with shape ``(B, 1, H, W)``
        """
        if not ("teacher_features" in kwargs and "student_features" in kwargs):
            msg = f"Expected keys `teacher_features` and `student_features. Found {kwargs.keys()}"
            raise ValueError(msg)

        teacher_features: dict[str, torch.Tensor] = kwargs["teacher_features"]
        student_features: dict[str, torch.Tensor] = kwargs["student_features"]
        image_size: tuple[int, int] | torch.Size = kwargs["image_size"]

        return self.compute_anomaly_map(teacher_features, student_features, image_size)
Generate anomaly map from teacher and student features.

        Expects the following keys in ``kwargs``:
        - ``teacher_features``: Dictionary of teacher network features
        - ``student_features``: Dictionary of student network features
        - ``image_size``: Target size for the anomaly map

        Args:
            kwargs (dict[str, torch.Tensor]): Keyword arguments containing
                required inputs

        Example:
            >>> generator = AnomalyMapGenerator()
            >>> anomaly_map = generator(
            ...     teacher_features=teacher_features,
            ...     student_features=student_features,
            ...     image_size=(256, 256)
            ... )

        Raises:
            ValueError: If required keys are missing from ``kwargs``

        Returns:
            torch.Tensor: Anomaly map with shape ``(B, 1, H, W)``
        
src/anomalib/models/image/stfpm/anomaly_map.py