code: def create_model():
      """Build the model and look for saved model checkpoints in case we can
      resume from one.
      """
      logger = logging.getLogger(__name__)
      start_iter = 0
      checkpoints = {}
      output_dir = get_output_dir(cfg.TRAIN.DATASETS, training=True)
      weights_file = cfg.TRAIN.WEIGHTS
      if cfg.TRAIN.AUTO_RESUME:
          # Check for the final model (indicates training already finished)
          final_path = os.path.join(output_dir, "model_final.pkl")
          if os.path.exists(final_path):
              logger.info("model_final.pkl exists; no need to train!")
              return None, None, None, {"final": final_path}, output_dir
  
          # Find the most recent checkpoint (highest iteration number)
          files = os.listdir(output_dir)
          for f in files:
              iter_string = re.findall(
                  r"(?<=model_iter)\d+(?=\.pkl)", f
              )
              if len(iter_string) > 0:
                  checkpoint_iter = int(iter_string[0])
                  if checkpoint_iter > start_iter:
                      # Start one iteration immediately after the checkpoint iter
                      start_iter = checkpoint_iter + 1
                      resume_weights_file = f
  
          if start_iter > 0:
              # Override the initialization weights with the found checkpoint
              weights_file = os.path.join(
                  output_dir, resume_weights_file
              )
              logger.info(
                  "========> Resuming from checkpoint {} at start iter {}".format(
                      weights_file, start_iter
                  )
              )
  
      logger.info("Building model: {}".format(cfg.MODEL.TYPE))
      model = model_builder.create(cfg.MODEL.TYPE, train=True)
      if cfg.MEMONGER:
          optimize_memory(model)
      # Performs random weight initialization as defined by the model
      workspace.RunNetOnce(model.param_init_net)
      return model, weights_file, start_iter, checkpoints, output_dir
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import cv2
  import logging
  import numpy
  import os
  import re
  from caffe2.python import memonger
  from caffe2.python import workspace
  from detectron.core.config import cfg
  from detectron.core.config import get_output_dir
  from detectron.datasets.roidb import combined_roidb_for_training
  from detectron.modeling import model_builder
  from detectron.utils import lr_policy
  from detectron.utils.training_stats import TrainingStats
  import detectron.utils.env
  import detectron.utils.net
label_desc: Use image node_id 2 for calling a global function with example usage: create_model() and returns: model,  weights_file,  start_iter,  checkpoints,  output_dir, None,  None,  None,  dict,  output_dir