def decision_function(self, X):
        """Predict raw anomaly score of X using the fitted detector.

        The anomaly score of an input sample is computed based on different
        detector algorithms. For consistency, outliers are assigned with
        larger anomaly scores.

        Parameters
        ----------
        X : numpy array of shape (n_samples, n_features)
            The training input samples. Sparse matrices are accepted only
            if they are supported by the base estimator.

        Returns
        -------
        anomaly_scores : numpy array of shape (n_samples,)
            The anomaly score of the input samples.
        """
        check_is_fitted(self, ['decision_scores_'])
        X = check_array(X)

        if self.preprocessing:
            X_norm = self.scaler_.transform(X)
        else:
            X_norm = np.copy(X)

        X_norm = torch.tensor(X_norm, dtype=torch.float32)

        # Predict on X
        pred_scores = []

        self.query_model.eval()
        with torch.no_grad():
            for i in range(X_norm.shape[0]):
                if self.verbose == 1:
                    print(
                        'query sample {} / {}'.format(i + 1, X_norm.shape[0]))

                query_sample = X_norm[[i],].to(self.device)

                zeros = torch.zeros((1, self.latent_dim_G)).to(self.device)
                z, sample_gen, sample_disc_latent = self.query_model(zeros)
                sample_disc_latent_original = self.discriminator(query_sample)

                loss_recon_gen = torch.mean(torch.mean(
                    torch.abs(query_sample - sample_gen), axis=-1))
                loss_recon_disc = torch.mean(torch.mean(
                    torch.abs(
                        sample_disc_latent_original - sample_disc_latent),
                    axis=-1))
                total_loss = loss_recon_gen + loss_recon_disc
                pred_scores.append(total_loss.item())

        return np.array(pred_scores)
Predict raw anomaly score of X using the fitted detector.

        The anomaly score of an input sample is computed based on different
        detector algorithms. For consistency, outliers are assigned with
        larger anomaly scores.

        Parameters
        ----------
        X : numpy array of shape (n_samples, n_features)
            The training input samples. Sparse matrices are accepted only
            if they are supported by the base estimator.

        Returns
        -------
        anomaly_scores : numpy array of shape (n_samples,)
            The anomaly score of the input samples.
        
pyod/models/anogan.py