def encode(self, features: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
        """Encode input features to latent space using normalizing flow.

        Args:
            features (torch.Tensor): Input features from feature extractor.

        Returns:
            tuple[torch.Tensor, torch.Tensor]: Tuple containing:
                - Latent variables from flow transformation
                - Log-Jacobian determinant of the transformation
        """
        z, ljd = self.flow(features, rev=False)
        if len(self.feature_extractor.scales) == 1:
            z = [z]
        return z, ljd
Encode input features to latent space using normalizing flow.

        Args:
            features (torch.Tensor): Input features from feature extractor.

        Returns:
            tuple[torch.Tensor, torch.Tensor]: Tuple containing:
                - Latent variables from flow transformation
                - Log-Jacobian determinant of the transformation
        
src/anomalib/models/image/uflow/torch_model.py