code: def test_init_detector(config, devices):
      assert all([device in ["cpu", "cuda"] for device in devices])
  
      project_dir = os.path.abspath(
          os.path.dirname(os.path.dirname(__file__))
      )
      project_dir = os.path.join(project_dir, "..")
  
      config_file = os.path.join(project_dir, config)
  
      # test init_detector with config_file: str and cfg_options
      cfg_options = dict(
          model=dict(
              backbone=dict(
                  depth=18,
                  init_cfg=dict(
                      type="Pretrained",
                      checkpoint="torchvision://resnet18",
                  ),
              )
          )
      )
  
      for device in devices:
          if device == "cuda" and not torch.cuda.is_available():
              pytest.skip("test requires GPU and torch+cuda")
  
          model = init_detector(
              config_file, device=device, cfg_options=cfg_options
          )
  
          # test init_detector with :obj:`Path`
          config_path_object = Path(config_file)
          model = init_detector(config_path_object, device=device)
  
          # test init_detector with undesirable type
          with pytest.raises(TypeError):
              config_list = [config_file]
              model = init_detector(config_list)
  
file_path: mmdetection/tests/test_apis/test_inference.py
imports: import os
  from pathlib import Path
  import numpy
  import pytest
  import torch
  from mmdet.apis import inference_detector, init_detector
  from mmdet.structures import DetDataSample
  from mmdet.utils import register_all_modules
label_desc: Use image node_id 1 for calling a global function with example usage: test_init_detector(config, devices) without return types