code: def resume(model, optimizer, resume_model):
      if resume_model is not None:
          logger.info("Resume model from {}".format(resume_model))
          if os.path.exists(resume_model):
              resume_model = os.path.normpath(resume_model)
              ckpt_path = os.path.join(resume_model, "model.pdparams")
              para_state_dict = paddle.load(ckpt_path)
              ckpt_path = os.path.join(resume_model, "model.pdopt")
              opti_state_dict = paddle.load(ckpt_path)
              model.set_state_dict(para_state_dict)
              optimizer.set_state_dict(opti_state_dict)
  
              iter = resume_model.split("_")[-1]
              iter = int(iter)
              return iter
          else:
              raise ValueError(
                  "Directory of the model needed to resume is not Found: {}".format(
                      resume_model
                  )
              )
      else:
          logger.info("No model needed to resume.")
  
imports: import os
  import contextlib
  import tempfile
  import random
  from urllib.parse import urlparse, unquote
  import yaml
  import numpy
  import paddle
  import cv2
  from paddleseg.utils import logger, seg_env, get_sys_env
  from paddleseg.utils.download import download_file_and_uncompress
label_desc: Use image node_id 11 for calling a global function with example usage: resume(model, optimizer, resume_model) and returns: iter