code: def load_model(output_path, model, opt=None, lr_scheduler=None):
      def version(x):
          x = int(x.split("_")[-1])
          return x
  
      ckpt_paths = glob.glob(os.path.join(output_path, "model_*"))
      steps = 0
      if len(ckpt_paths) > 0:
          output_dir = sorted(ckpt_paths, key=version, reverse=True)[0]
  
          model_state_dict = paddle.load(
              os.path.join(output_dir, "ckpt.pdparams")
          )
          model.set_state_dict(model_state_dict)
          log.info("load model from  %s" % output_dir)
  
          if opt is not None and os.path.exists(
              os.path.join(output_dir, "opt.pdparams")
          ):
              opt_state_dict = paddle.load(
                  os.path.join(output_dir, "opt.pdparams")
              )
              opt.set_state_dict(opt_state_dict)
              log.info("restore optimizer")
  
          if lr_scheduler is not None and os.path.exists(
              os.path.join(output_dir, "lr_scheduler.pdparams")
          ):
              lr_scheduler_state_dict = paddle.load(
                  os.path.join(output_dir, "lr_scheduler.pdparams")
              )
              lr_scheduler.set_state_dict(lr_scheduler_state_dict)
              log.info("restore lr_scheduler")
  
          if os.path.exists(
              os.path.join(output_dir, "lr_scheduler.pdparams")
          ):
              steps = paddle.load(os.path.join(output_dir, "step"))[
                  "global_step"
              ]
              log.info("restore steps")
      return steps
  
file_path: PGL/examples/kddcup2021/MAG240M/r_unimp/utils.py
imports: import os
  import paddle
  import paddle.distributed
  import glob
  import shutil
  from pgl.utils.logger import log
label_desc: Use image node_id 3 for calling a global function with example usage: load_model(output_path, model, opt, lr_scheduler) and returns: steps, x