code: def config_model(model: torch.nn.Module, args, mode: str) -> None:
      model.to(args.device)
      model.train()
  
      # load checkpoint
      if mode == "train" and args.tr_ctn:
          ckpt = torch.load(
              os.path.join(
                  args.ckpt_dir, f"{args.model_name}_last.ckpt"
              )
          )
          model.load_state_dict(ckpt["state_dict"])
          args.ctn_epoch = ckpt["epoch"] + 1
          print(f'#IN#Continue training from Epoch {ckpt["epoch"]}...')
  
      if mode == "test" or mode == "explain":
          try:
              ckpt = torch.load(args.test_ckpt)
          except FileNotFoundError:
              print(
                  f"#E#Checkpoint not found at {os.path.abspath(args.test_ckpt)}"
              )
              exit(1)
          model.load_state_dict(ckpt["state_dict"])
          print(f'#IN#Loading best Checkpoint {ckpt["epoch"]}...')
  
imports: from inspect import isclass
  import dig.xgraph.models.models
  import torch
  import sys
  import os
label_desc: Use image node_id 2 for calling a global function with example usage: config_model(model, args, mode) without return types