text: # -*- coding: utf-8 -*-
  import os
  import random
  import shutil
  import time
  import warnings
  
  import torch
  import torch.nn as nn
  import torch.nn.parallel
  import torch.backends.cudnn as cudnn
  import torch.distributed as dist
  import torch.optim
  import torch.multiprocessing as mp
  import torch.utils.data
  import torch.utils.data.distributed
  import torchvision.utils as vutils
  
  from network import vgg, resnet
  from tensorboardX import SummaryWriter
  from utils.util_args import get_args
  from utils.util_acc import accuracy, adjust_learning_rate, \
      save_checkpoint, AverageEpochMeter, SumEpochMeter, \
      ProgressEpochMeter, calculate_IOU, Logger
  from utils.util_loader import data_loader
  from utils.util_bbox import *
  from utils.util_cam import *
  
  def load_model(model, optimizer, args):
      if os.path.isfile(args.resume):
          if args.gpu == 0:
              print("=> loading checkpoint '{}'".format(args.resume))
          checkpoint = torch.load(args.resume)
          args.start_epoch = checkpoint['epoch']
          best_acc1 = checkpoint['best_acc1']
          if args.gpu is not None:
              # best_acc1 may be from a checkpoint from a different GPU
              best_acc1 = best_acc1.to(args.gpu)
          model.load_state_dict(checkpoint['state_dict'])
          optimizer.load_state_dict(checkpoint['optimizer'])
          if args.gpu == 0:
              print("=> loaded checkpoint '{}' (epoch {})"
                    .format(args.resume, checkpoint['epoch']))
      else:
          if args.gpu == 0:
              print("=> no checkpoint found at '{}'".format(args.resume))
  
      return model, optimizer
  