def adv_train_generator(self, g_step):
        """
        The gen is trained by MLE-like objective.
        """
        total_g_loss = 0
        for step in range(g_step):
            inp, target = GenDataIter.prepare(self.gen.sample(cfg.batch_size, cfg.batch_size), gpu=cfg.CUDA)

            # ===Train===
            rewards = self.get_mali_reward(target)
            adv_loss = self.gen.adv_loss(inp, target, rewards)
            self.optimize(self.gen_adv_opt, adv_loss)
            total_g_loss += adv_loss.item()

        # ===Test===
        self.log.info('[ADV-GEN]: g_loss = %.4f, %s' % (total_g_loss, self.cal_metrics(fmt_str=True)))

        The gen is trained by MLE-like objective.
        
instructor/oracle_data/maligan_instructor.py