def forward(
        self,
        batch: torch.Tensor,
    ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor] | InferenceBatch:
        """Forward pass through GANomaly model.

        Args:
            batch (torch.Tensor): Batch of input images

        Returns:
            tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor] |
            InferenceBatch:
                If training:
                    - Padded input batch
                    - Generated images
                    - First encoder's latent vectors
                    - Second encoder's latent vectors
                If inference:
                    - Batch containing anomaly scores
        """
        padded_batch = pad_nextpow2(batch)
        fake, latent_i, latent_o = self.generator(padded_batch)
        if self.training:
            return padded_batch, fake, latent_i, latent_o
        scores = torch.mean(torch.pow((latent_i - latent_o), 2), dim=1).view(-1)  # convert nx1x1 to n
        return InferenceBatch(pred_score=scores)
Forward pass through GANomaly model.

        Args:
            batch (torch.Tensor): Batch of input images

        Returns:
            tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor] |
            InferenceBatch:
                If training:
                    - Padded input batch
                    - Generated images
                    - First encoder's latent vectors
                    - Second encoder's latent vectors
                If inference:
                    - Batch containing anomaly scores
        
src/anomalib/models/image/ganomaly/torch_model.py