code: def save_model(
      model,
      optimizer,
      model_path,
      logger,
      is_best=False,
      prefix="ppocr",
      **kwargs,
  ):
      """
      save model to the target path
      """
      _mkdir_if_not_exist(model_path, logger)
      model_prefix = os.path.join(model_path, prefix)
      paddle.save(model.state_dict(), model_prefix + ".pdparams")
      if type(optimizer) is list:
          paddle.save(
              optimizer[0].state_dict(), model_prefix + ".pdopt"
          )
          paddle.save(
              optimizer[1].state_dict(), model_prefix + "_1" + ".pdopt"
          )
  
      else:
          paddle.save(optimizer.state_dict(), model_prefix + ".pdopt")
  
      # # save metric and config
      # with open(model_prefix + '.states', 'wb') as f:
      #     pickle.dump(kwargs, f, protocol=2)
      if is_best:
          logger.info("save best model is to {}".format(model_prefix))
      else:
          logger.info("save model in {}".format(model_prefix))
  
imports: import paddle
  import numpy
  import os
  import paddle.nn
  import paddle.distributed
  from loss import build_loss, LossDistill, DMLLoss, KLJSLoss
  from optimizer import create_optimizer
  from data_loader import build_dataloader
  from metric import create_metric
  from mv3 import MobileNetV3_large_x0_5, distillmv3_large_x0_5, build_model
  from config import preprocess
  import time
  from paddleslim.dygraph.quant import QAT
  from slim.slim_quant import PACT, quant_config
  from slim.slim_fpgm import prune_model
  from utils import load_model
label_desc: Use image node_id 2 for calling a global function with example usage: save_model(model, optimizer, model_path, logger, is_best, prefix) without return types