def fit(self, X_train, y_train, ratio=None):
        """
        Deep SAD, a method for deep semi-supervised anomaly detection.

        :arg DATASET_NAME: Name of the dataset to load.
        :arg NET_NAME: Name of the neural network to use.
        :arg XP_PATH: Export path for logging the experiment.
        """

        # Set seed (using myutils)
        self.utils.set_seed(self.seed)

        # Set the number of threads used for parallelizing CPU operations
        if self.num_threads > 0:
            torch.set_num_threads(self.num_threads)
        logging.info('Computation device: %s' % self.device)
        logging.info('Number of threads: %d' % self.num_threads)
        logging.info('Number of dataloader workers: %d' % self.n_jobs_dataloader)

        # Load data
        data = {'X_train': X_train, 'y_train': y_train}
        dataset = load_dataset(data=data, train=True)
        input_size = dataset.train_set.data.size(1) #input size

        # Initialize DeepSAD model and set neural network phi
        self.deepSAD = deepsad(self.eta)
        self.deepSAD.set_network(self.net_name, input_size)

        # If specified, load Deep SAD model (center c, network weights, and possibly autoencoder weights)
        if self.load_model:
            self.deepSAD.load_model(model_path=self.load_model, load_ae=True, map_location=self.device)
            logging.info('Loading model from %s.' % self.load_model)

        logging.info('Pretraining: %s' % self.pretrain)
        if self.pretrain:
            # Pretrain model on dataset (via autoencoder)
            self.deepSAD.pretrain(dataset,
                             input_size,
                             optimizer_name=self.ae_optimizer_name,
                             lr=self.ae_lr,
                             n_epochs=self.ae_n_epochs,
                             lr_milestones=self.ae_lr_milestone,
                             batch_size=self.ae_batch_size,
                             weight_decay=self.ae_weight_decay,
                             device=self.device,
                             n_jobs_dataloader=self.n_jobs_dataloader)

        # Train model on dataset
        self.deepSAD.train(dataset,
                          optimizer_name=self.optimizer_name,
                          lr=self.lr,
                          n_epochs=self.n_epochs,
                          lr_milestones=self.lr_milestone,
                          batch_size=self.batch_size,
                          weight_decay=self.weight_decay,
                          device=self.device,
                          n_jobs_dataloader=self.n_jobs_dataloader)

        # Save results, model, and configuration
        # deepSAD.save_results(export_json=xp_path + '/results.json')
        # deepSAD.save_model(export_model=xp_path + '/model.tar')
        # cfg.save_config(export_json=xp_path + '/config.json')

        # Plot most anomalous and most normal test samples
        # indices, labels, scores = zip(*deepSAD.results['test_scores'])
        # indices, labels, scores = np.array(indices), np.array(labels), np.array(scores)
        # idx_all_sorted = indices[np.argsort(scores)]  # from lowest to highest score
        # idx_normal_sorted = indices[labels == 0][np.argsort(scores[labels == 0])]  # from lowest to highest score

        return self

        Deep SAD, a method for deep semi-supervised anomaly detection.

        :arg DATASET_NAME: Name of the dataset to load.
        :arg NET_NAME: Name of the neural network to use.
        :arg XP_PATH: Export path for logging the experiment.
        
adbench/baseline/DeepSAD/src/run.py