class_docstr: The basic Trainer for basic training and evaluation strategies in text generation systems.
  
  This class defines common functions for training and evaluation processes of most text generation system models,
  including `fit()`, `evaluate()`, `resume_checkpoint()` and some other features helpful for model training and
  evaluation.
  
  Generally speaking, this class can serve most text generation system models, If the training process of the model
  is to simply optimize a single loss without involving any complex training strategies, such as adversarial learning,
  pre-training and so on.
  
  Initializing the Trainer needs two parameters: `config` and `model`. `config` records the parameters' information
  for controlling training and evaluation, such as `learning_rate`, `epochs` and so on.
  More information can be found in [placeholder]. `model` is the instantiated object of a Model Class.
class_docstr_tok: ["The","basic","Trainer","for","basic","training","and","evaluation","strategies","in","text","generation","systems",".","This","class","defines","common","functions","for","training","and","evaluation","processes","of","most","text","generation","system","models",",","including","`","fit","(",")","`",",","`","evaluate","(",")","`",",","`","resume_checkpoint","(",")","`","and","some","other","features","helpful","for","model","training","and","evaluation",".","Generally","speaking",",","this","class","can","serve","most","text","generation","system","models",",","If","the","training","process","of","the","model","is","to","simply","optimize","a","single","loss","without","involving","any","complex","training","strategies",",","such","as","adversarial","learning",",","pre-training","and","so","on",".","Initializing","the","Trainer","needs","two","parameters",":","`","config","`","and","`","model","`",".","`","config","`","records","the","parameters","'","information","for","controlling","training","and","evaluation",",","such","as","`","learning_rate","`",",","`","epochs","`","and","so","on",".","More","information","can","be","found","in","[","placeholder","]",".","`","model","`","is","the","instantiated","object","of","a","Model","Class","."]
code: def save_checkpoint(self):
      serial_idx = self.timestamp.valid_epoch
      serial_of_soft_link = self.best_valid_timestamp.valid_epoch
      serialized_save(
          self.accelerator.unwrap_model(self.model),
          self.optimizer,
          self._get_checkpoint(),
          serial=serial_idx,
          serial_of_soft_link=serial_of_soft_link,
          path_without_extension=self.saved_model_filename,
          tag="epoch",
          extension_name="pth",
          max_save=self.max_save,
      )
  
imports: import collections
  import os
  from accelerate.logging import get_logger
  from typing import Optional, Union, List, Dict
  import math
  import torch
  import torch.optim
  import transformers
  from accelerate import Accelerator
  from accelerate.utils import set_seed
  from torch.utils.data import DataLoader
  from tqdm import tqdm
  from textbox import Config
  from textbox.utils.dashboard import get_dashboard, Timestamp, EpochTracker
  from .scheduler import AbstractScheduler, InverseSquareRootScheduler, CosineScheduler, LinearScheduler, ConstantScheduler
  from torch.utils.data import DataLoader
  from ..evaluator import BaseEvaluator
  from ..model.abstract_model import AbstractModel
  from ..utils import serialized_save, init_seed
  from ..utils.enum_type import PLM_MODELS, RNN_MODELS
label_desc: Use image node_id 10 for calling the Trainer obj's underlying member method code with example usage: obj.save_checkpoint() without return types