code: def build_model_saver(
      model_opt, opt, model, vocabs, optim, device_id
  ):
      # _check_save_model_path
      save_model_path = os.path.abspath(opt.save_model)
      os.makedirs(os.path.dirname(save_model_path), exist_ok=True)
  
      model_saver = ModelSaver(
          opt.save_model,
          model,
          model_opt,
          vocabs,
          optim,
          opt.keep_checkpoint,
          opt.save_format,
          device_id,
      )
      return model_saver
  
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 for calling a global function with example usage: build_model_saver(model_opt, opt, model, vocabs, optim, device_id) and returns: model_saver