def pretrain(self, dataset: BaseADDataset, optimizer_name: str = 'adam', lr: float = 0.001, n_epochs: int = 100,
                 lr_milestones: tuple = (), batch_size: int = 128, weight_decay: float = 1e-6, device: str = 'cuda',
                 n_jobs_dataloader: int = 0):
        """Pretrains a variational autoencoder (M1) for the Semi-Supervised Deep Generative model."""

        # Train
        self.vae_optimizer_name = optimizer_name
        self.vae_trainer = VAETrainer(optimizer_name=optimizer_name, lr=lr, n_epochs=n_epochs,
                                      lr_milestones=lr_milestones, batch_size=batch_size, weight_decay=weight_decay,
                                      device=device, n_jobs_dataloader=n_jobs_dataloader)
        self.vae_net = self.vae_trainer.train(dataset, self.vae_net)
        # Get train results
        self.vae_results['train_time'] = self.vae_trainer.train_time

        # Test
        self.vae_trainer.test(dataset, self.vae_net)
        # Get test results
        self.vae_results['test_auc'] = self.vae_trainer.test_auc
        self.vae_results['test_time'] = self.vae_trainer.test_time
Pretrains a variational autoencoder (M1) for the Semi-Supervised Deep Generative model.
adbench/baseline/DeepSAD/src/baselines/SemiDGM.py