def train_mediator(self, cur_epoch, d_step):
        """
        Training the mediator on real_data_samples (positive) and generated samples from gen (negative).
        """
        d_loss = []
        for step in range(d_step):
            # prepare loader for training
            real = list(self.oracle_data.loader)[cur_epoch % len(self.oracle_data.loader)]  # traverse all real data
            real_inp, real_tar = real['input'], real['target']
            fake_inp, fake_tar = GenDataIter.prepare(self.gen.sample(cfg.batch_size, cfg.batch_size), gpu=cfg.CUDA)
            if cfg.CUDA:
                real_inp, real_tar = real_inp.cuda(), real_tar.cuda()

            real_pred = self.dis.get_pred(real_inp, real_tar)
            fake_pred = self.dis.get_pred(fake_inp, fake_tar)
            loss = -torch.mean(real_pred + fake_pred) / 2.0

            self.optimize(self.dis_opt, loss)
            d_loss.append(loss.item())

        return np.mean(d_loss)

        Training the mediator on real_data_samples (positive) and generated samples from gen (negative).
        
instructor/oracle_data/cot_instructor.py