code: def test_inference_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
      rng = np.random.RandomState(0)
      img1 = rng.randint(0, 255, (32, 32, 3), dtype=np.uint8)
      img2 = rng.randint(0, 255, (32, 32, 3), dtype=np.uint8)
  
      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)
          result = inference_detector(model, img1)
          assert isinstance(result, DetDataSample)
          result = inference_detector(model, [img1, img2])
          assert isinstance(result, list) and len(result) == 2
  
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 2 for calling a global function with example usage: test_inference_detector(config, devices) without return types