code: def test_training_engine(
      config_file: str, is_iteration_based: bool, tmp_path: Path
  ) -> None:
      opts = get_config(config_file=config_file)
  
      # device set-up
      opts = device_setup(opts)
  
      setattr(opts, "ddp.rank", 0)
  
      is_master_node = is_master(opts)
  
      # create the directory for saving results
      # Parallel tests causes issues when save_dir is accessed by multiple workers.
      # Therefore, we use a unique random path here and use that as a save location.
      save_dir = str(tmp_path)
      setattr(opts, "common.results_loc", save_dir)
  
      run_label = getattr(opts, "common.run_label", "run_1")
      exp_dir = "{}/{}".format(save_dir, run_label)
      setattr(opts, "common.exp_loc", exp_dir)
  
      # if results directory exists, delete it
      if os.path.isdir(save_dir):
          shutil.rmtree(save_dir)
  
      create_directories(
          dir_path=exp_dir, is_master_node=is_master_node
      )
  
      setattr(opts, "dev.num_gpus", 0)
      setattr(opts, "dataset.workers", 0)
  
      if getattr(opts, "dataset.name", "coco_ssd"):
          # coco_map metric requires access to instances_val2017.json file
          coco_annotations_path = os.path.join(
              os.path.dirname(__file__), "data", "coco"
          )
          setattr(opts, "dataset.root_val", coco_annotations_path)
  
      norm_name = getattr(
          opts, "model.normalization.name", "batch_norm"
      )
  
      if norm_name is not None and norm_name in [
          "sync_batch_norm",
          "sbn",
      ]:
          setattr(opts, "model.normalization.name", "batch_norm")
  
      # adjust the batch size
      setattr(opts, "dataset.train_batch_size0", 2)
      setattr(opts, "dataset.val_batch_size0", 2)
      setattr(opts, "dev.device_id", None)
      setattr(opts, "dev.device", torch.device("cpu"))
  
      setattr(opts, "sampler.vbs.crop_size_width", 32)
      setattr(opts, "sampler.vbs.crop_size_height", 32)
      setattr(opts, "sampler.bs.crop_size_width", 32)
      setattr(opts, "sampler.bs.crop_size_height", 32)
      setattr(opts, "sampler.vbs.min_crop_size_width", 32)
      setattr(opts, "sampler.vbs.min_crop_size_height", 32)
      setattr(opts, "sampler.vbs.max_crop_size_width", 64)
      setattr(opts, "sampler.vbs.max_crop_size_height", 64)
  
      # We need to disable mixed_precision if testing on CPU only.
      setattr(opts, "common.mixed_precision", False)
  
      # removing pretrained models (if any) for now to reduce test time as well as access issues
      unset_pretrained_models_from_opts(opts)
  
      main(opts=opts, is_iteration_based=is_iteration_based)
  
      # delete the results directory folder
      if os.path.isdir(save_dir):
          shutil.rmtree(save_dir)
  
imports: import os.path
  import sys
  from pathlib import Path
  import pytest
  import math
  import random
  import shutil
  import torch
  from torch.cuda.amp import GradScaler
  from cvnets import EMA, get_model
  from engine import Trainer
  from loss_fn import build_loss_fn
  from optim import build_optimizer
  from optim.scheduler import build_scheduler
  from tests.configs import get_config
  from tests.dummy_loader import create_train_val_loader
  from tests.test_utils import unset_pretrained_models_from_opts
  from utils.checkpoint_utils import load_checkpoint, load_model_state
  from utils.common_utils import create_directories, device_setup
  from utils.ddp_utils import is_master
label_desc: Use image node_id 2 for calling a global function with example usage: test_training_engine(config_file, is_iteration_based, tmp_path) without return types