class_docstr: Transformers base model (for working with pytorch-transformers models)
class_docstr_tok: ["Transformers","base","model","(","for","working","with","pytorch-transformers","models",")"]
code: def update_best_model(
      self,
      dev_data_set,
      test_data_set,
      best_dev,
      best_dev_test,
      best_result_file,
      save_path=None,
  ):
      new_best_dev = best_dev
      new_test_dev = best_dev_test
      set_test = False
  
      for i, ds in enumerate([dev_data_set, test_data_set]):
          if ds is None:  # got no data loader
              continue
          if isinstance(ds, DataLoader):
              ds = [ds]
          for d in ds:
              logits, label_ids = self._evaluate(d)
              f1 = self.evaluate_predictions(logits, label_ids)
              if f1:
                  if i == 0 and f1 > best_dev:  # dev set
                      new_best_dev = f1
                      set_test = True
                      if save_path is not None:
                          self.save_model(
                              save_path, args=self.training_args
                          )
              elif set_test:
                  new_test_dev = f1
                  set_test = False
                  if best_result_file is not None:
                      with open(best_result_file, "a+") as f:
                          f.write(
                              "best dev= "
                              + str(new_best_dev)
                              + ", test= "
                              + str(new_test_dev)
                          )
      logger.info(
          "\n\nBest dev=%s. test=%s\n",
          str(new_best_dev),
          str(new_test_dev),
      )
      return new_best_dev, new_test_dev
  
imports: import io
  import logging
  import os
  from typing import List, Union
  import torch
  from torch.utils.data import DataLoader
  from tqdm import tqdm, trange
  from transformers import AdamW, BertConfig, BertTokenizer, RobertaConfig, RobertaTokenizer, XLMConfig, XLMTokenizer, XLNetConfig, XLNetTokenizer, get_linear_schedule_with_warmup
  from nlp_architect.models import TrainableModel
  from nlp_architect.models.transformers.quantized_bert import QuantizedBertConfig
label_desc: Use image node_id 15 for calling the TransformerBase obj's underlying member method code with example usage: obj.update_best_model(dev_data_set, test_data_set, best_dev, best_dev_test, best_result_file, save_path) and returns: new_best_dev,  new_test_dev