code: def test_yolov3_neck():
      # num_scales, in_channels, out_channels must be same length
      with pytest.raises(AssertionError):
          YOLOV3Neck(
              num_scales=3, in_channels=[16, 8, 4], out_channels=[8, 4]
          )
  
      # len(feats) must equal to num_scales
      with pytest.raises(AssertionError):
          neck = YOLOV3Neck(
              num_scales=3,
              in_channels=[16, 8, 4],
              out_channels=[8, 4, 2],
          )
          feats = (torch.rand(1, 4, 16, 16), torch.rand(1, 8, 16, 16))
          neck(feats)
  
      # test normal channels
      s = 32
      in_channels = [16, 8, 4]
      out_channels = [8, 4, 2]
      feat_sizes = [
          s // 2**i for i in range(len(in_channels) - 1, -1, -1)
      ]
      feats = [
          torch.rand(1, in_channels[i], feat_sizes[i], feat_sizes[i])
          for i in range(len(in_channels) - 1, -1, -1)
      ]
      neck = YOLOV3Neck(
          num_scales=3,
          in_channels=in_channels,
          out_channels=out_channels,
      )
      outs = neck(feats)
  
      assert len(outs) == len(feats)
      for i in range(len(outs)):
          assert outs[i].shape == (
              1,
              out_channels[i],
              feat_sizes[i],
              feat_sizes[i],
          )
  
      # test more flexible setting
      s = 32
      in_channels = [32, 8, 16]
      out_channels = [19, 21, 5]
      feat_sizes = [
          s // 2**i for i in range(len(in_channels) - 1, -1, -1)
      ]
      feats = [
          torch.rand(1, in_channels[i], feat_sizes[i], feat_sizes[i])
          for i in range(len(in_channels) - 1, -1, -1)
      ]
      neck = YOLOV3Neck(
          num_scales=3,
          in_channels=in_channels,
          out_channels=out_channels,
      )
      outs = neck(feats)
  
      assert len(outs) == len(feats)
      for i in range(len(outs)):
          assert outs[i].shape == (
              1,
              out_channels[i],
              feat_sizes[i],
              feat_sizes[i],
          )
  
file_path: mmdetection/tests/test_models/test_necks/test_necks.py
imports: import pytest
  import torch
  from torch.nn.modules.batchnorm import _BatchNorm
  from mmdet.models.necks import FPG, FPN, FPN_CARAFE, NASFCOS_FPN, NASFPN, SSH, YOLOXPAFPN, ChannelMapper, DilatedEncoder, DyHead, SSDNeck, YOLOV3Neck
label_desc: Use image node_id 4 for calling a global function with example usage: test_yolov3_neck() without return types