def forward(self, image: torch.Tensor) -> torch.Tensor | InferenceBatch:
        """Process input image through the model.

        During training, returns latent variables and log-Jacobian determinant.
        During inference, returns anomaly scores and anomaly map.

        Args:
            image (torch.Tensor): Input image tensor of shape
                ``(batch_size, channels, height, width)``.

        Returns:
            torch.Tensor | InferenceBatch: During training, returns tuple of
                ``(latent_vars, log_jacobian)``. During inference, returns
                ``InferenceBatch`` with anomaly scores and map.
        """
        features = self.feature_extractor(image)
        z, ljd = self.encode(features)

        if self.training:
            return z, ljd

        anomaly_map = self.anomaly_map_generator(z)
        pred_score = torch.amax(anomaly_map, dim=(-2, -1))
        return InferenceBatch(pred_score=pred_score, anomaly_map=anomaly_map)
Process input image through the model.

        During training, returns latent variables and log-Jacobian determinant.
        During inference, returns anomaly scores and anomaly map.

        Args:
            image (torch.Tensor): Input image tensor of shape
                ``(batch_size, channels, height, width)``.

        Returns:
            torch.Tensor | InferenceBatch: During training, returns tuple of
                ``(latent_vars, log_jacobian)``. During inference, returns
                ``InferenceBatch`` with anomaly scores and map.
        
src/anomalib/models/image/uflow/torch_model.py