def METHOD_NAME(self, epoch, data_loader, train=True):
    """
    loop over the data_loader for training or testing
    if on train status, backward operation is activated
    and also auto save the model every peoch
    :param epoch: current epoch index
    :param data_loader: torch.utils.data.DataLoader for iteration
    :param train: boolean value of is train or test
    :return: None
    """
    str_code = "train" if train else "test"
    data_iter = enumerate(data_loader)
    avg_loss = 0.0
    total_correct = 0
    total_element = 0
    for i, data in data_iter:
        # 0. batch_data will be sent into the device(GPU or cpu)
        data = {key: value.to(self.device) for key, value in data.items()}
        # 1. forward the next_sentence_prediction and masked_lm model
        next_sent_output, mask_lm_output = self.model.forward(data["bert_input"], data["segment_label"])
        # 2-1. NLL(negative log likelihood) loss of is_next classification result
        next_loss = self.criterion(next_sent_output, data["is_next"])
        # 2-2. NLLLoss of predicting masked token word
        mask_loss = self.criterion(mask_lm_output.transpose(1, 2), data["bert_label"])
        # 2-3. Adding next_loss and mask_loss : 3.4 Pre-training Procedure
        loss = next_loss + mask_loss
        # 3. backward and optimization only in train
        if train:
            self.optim_schedule.zero_grad()
            loss.backward()
            self.optim_schedule.step_and_update_lr()
        # next sentence prediction accuracy
        correct = next_sent_output.argmax(dim=-1).eq(data["is_next"]).sum().item()
        avg_loss += loss.item()
        total_correct += correct
        total_element += data["is_next"].nelement()
        post_fix = {
            "epoch": epoch,
            "iter": i,
            "avg_loss": avg_loss / (i + 1),
            "avg_acc": total_correct / total_element * 100,
            "loss": loss.item()
        }
        if i % self.log_freq == 0:
            data_iter.write(str(post_fix))
        if self.debug and epoch == 1 and i == 0:
            torch.save(next_sent_output, self.debug)
    print("EP%d_%s, avg_loss=" % (epoch, str_code), avg_loss / len(data_iter), "total_acc=",
          total_correct * 100.0 / total_element)