class_docstr: Model trainer
  
  Args:
      model(paddle.nn.Layer) : Model to train or evaluate.
      optimizer(paddle.optimizer.Optimizer) : Optimizer for loss.
      use_gpu(bool) : Whether to use gpu to run.
      use_vdl(bool) : Whether to use visualdl to record training data.
      checkpoint_dir(str) : Directory where the checkpoint is saved, and the trainer will restore the
          state and model parameters from the checkpoint.
      compare_metrics(callable) : The method of comparing the model metrics. If not specified, the main
          metric return by `validation_step` will be used for comparison by default, the larger the
          value, the better the effect. This method will affect the saving of the best model. If the
          default behavior does not meet your requirements, please pass in a custom method.
  
          Example:
              .. code-block:: python
  
                  def compare_metrics(old_metric: dict, new_metric: dict):
                      mainkey = list(new_metric.keys())[0]
                      return old_metric[mainkey] < new_metric[mainkey]
code: def _load_metrics(self):
      metrics_file = os.path.join(self.checkpoint_dir, "metrics.pkl")
      if not os.path.exists(metrics_file):
          return
  
      with open(metrics_file, "rb") as file:
          self.best_metrics = pickle.load(file)
  
imports: import os
  import pickle
  import time
  from collections import defaultdict
  from typing import Any
  from typing import Callable
  from typing import Generic
  from typing import List
  import numpy
  import paddle
  from visualdl import LogWriter
  from paddlehub.utils.log import logger
  from paddlehub.utils.utils import Timer
label_desc: Use image node_id 7 for calling the Trainer obj's underlying member method code with example usage: obj._load_metrics() without return types