code: def load_model(model, cfg, load_fc=True):
      """
      Load pretrained model weights.
      """
      if os.path.isfile(cfg.CONFIG.MODEL.PRETRAINED_PATH):
          print(
              "=> loading checkpoint '{}'".format(
                  cfg.CONFIG.MODEL.PRETRAINED_PATH
              )
          )
          if cfg.DDP_CONFIG.GPU is None:
              checkpoint = torch.load(cfg.CONFIG.MODEL.PRETRAINED_PATH)
          else:
              # Map model to be loaded to specified single gpu.
              loc = "cuda:{}".format(cfg.DDP_CONFIG.GPU)
              checkpoint = torch.load(
                  cfg.CONFIG.MODEL.PRETRAINED_PATH, map_location=loc
              )
          model_dict = model.state_dict()
          if not load_fc:
              del model_dict["module.fc.weight"]
              del model_dict["module.fc.bias"]
          pretrained_dict = {
              k: v
              for k, v in checkpoint["state_dict"].items()
              if k in model_dict
          }
          unused_dict = {
              k: v
              for k, v in checkpoint["state_dict"].items()
              if not k in model_dict
          }
          not_found_dict = {
              k: v
              for k, v in model_dict.items()
              if not k in checkpoint["state_dict"]
          }
          print("unused model layers:", unused_dict.keys())
          print("not found layers:", not_found_dict.keys())
          model_dict.update(pretrained_dict)
          model.load_state_dict(model_dict)
          print(
              "=> loaded checkpoint '{}' (epoch {})".format(
                  cfg.CONFIG.MODEL.PRETRAINED_PATH, checkpoint["epoch"]
              )
          )
      else:
          print(
              "=> no checkpoint found at '{}'".format(
                  cfg.CONFIG.MODEL.PRETRAINED_PATH
              )
          )
  
      return model, None
  
file_path: gluon-cv/gluoncv/torch/utils/model_utils.py
imports: import os
  import hashlib
  import requests
  from tqdm import tqdm
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: load_model(model, cfg, load_fc) and returns: model,  None