def METHOD_NAME(self):
    time = datetime.now()
    epoch_bar = tqdm(
        range(self.epochs), desc="Train epoch", disable=not is_rank_0()
    )
    for epoch in range(self.epochs):
        step_bar = tqdm(
            range(self.train_dataloader.__len__()),
            desc="Train step of epoch %d" % epoch,
            disable=not is_rank_0(),
        )
        # train
        self.model.train()
        cnt = 0
        acc = 0
        dist = 0
        for chosen_ids, c_mask, reject_ids, r_mask in self.train_dataloader:
            chosen_ids = chosen_ids.squeeze(1).to(torch.cuda.current_device())
            c_mask = c_mask.squeeze(1).to(torch.cuda.current_device())
            reject_ids = reject_ids.squeeze(1).to(torch.cuda.current_device())
            r_mask = r_mask.squeeze(1).to(torch.cuda.current_device())
            chosen_reward = self.model(chosen_ids, attention_mask=c_mask)
            reject_reward = self.model(reject_ids, attention_mask=r_mask)
            loss = self.loss_fn(chosen_reward, reject_reward)
            self.strategy.backward(loss, self.model, self.optimizer)
            self.strategy.optimizer_step(self.optimizer)
            self.optimizer.zero_grad()
            cnt += 1
            if cnt == 100:
                self.scheduler.step()
                dist, acc = self.eval_acc(self.valid_dataloader)
                cnt = 0
                if is_rank_0():
                    log = pd.DataFrame(
                        [[step_bar.n, loss.item(), dist, acc]],
                        columns=["step", "loss", "dist", "acc"],
                    )
                    log.to_csv(
                        "log_%s.csv" % time, mode="a", header=False, index=False
                    )
            step_bar.update()
            step_bar.set_postfix({"dist": dist, "acc": acc})
        # eval
        dist, acc = self.eval_acc(self.eval_dataloader)
        if is_rank_0():
            log = pd.DataFrame(
                [[step_bar.n, loss.item(), dist, acc]],
                columns=["step", "loss", "dist", "acc"],
            )
            log.to_csv("log.csv", mode="a", header=False, index=False)
        epoch_bar.update()
        step_bar.set_postfix({"dist": dist, "acc": acc})
        step_bar.close()