class_docstr: Base class for model saving operations
  
  Inherited classes must implement private methods:
  * `_save`
  * `_rm_checkpoint
class_docstr_tok: ["Base","class","for","model","saving","operations","Inherited","classes","must","implement","private","methods",":","*","`","_save","`","*","`","_rm_checkpoint"]
code: def __init__(
      self,
      base_path,
      model,
      model_opt,
      vocabs,
      optim,
      keep_checkpoint=-1,
      save_format="pytorch",
      device_id=0,
  ):
      self.base_path = base_path
      self.model = model
      self.model_opt = model_opt
      self.vocabs = vocabs
      self.optim = optim
      self.last_saved_step = None
      self.keep_checkpoint = keep_checkpoint
      self.save_format = save_format
      self.device_id = device_id
  
      if keep_checkpoint > 0:
          self.checkpoint_queue = deque([], maxlen=keep_checkpoint)
          if save_format == "safetensors":
              self.model_queue = deque([], maxlen=keep_checkpoint)
  
file_path: OpenNMT-py/onmt/models/model_saver.py
imports: import os
  import torch
  import re
  from collections import deque
  from onmt.utils.logging import logger
  from onmt.inputters.inputter import vocabs_to_dict
  from onmt.modules.lora import lora_state_dict
label_desc: Use image node_id 1 to create a new ModelSaverBase object from inherited base classes: object with example: obj = ModelSaverBase(base_path, model, model_opt, vocabs, optim, keep_checkpoint, save_format, device_id)