code: def test_channel_mapper():
      """Tests ChannelMapper."""
      s = 64
      in_channels = [8, 16, 32, 64]
      feat_sizes = [s // 2**i for i in range(4)]  # [64, 32, 16, 8]
      out_channels = 8
      kernel_size = 3
      feats = [
          torch.rand(1, in_channels[i], feat_sizes[i], feat_sizes[i])
          for i in range(len(in_channels))
      ]
  
      # in_channels must be a list
      with pytest.raises(AssertionError):
          channel_mapper = ChannelMapper(
              in_channels=10,
              out_channels=out_channels,
              kernel_size=kernel_size,
          )
      # the length of channel_mapper's inputs must be equal to the length of
      # in_channels
      with pytest.raises(AssertionError):
          channel_mapper = ChannelMapper(
              in_channels=in_channels[:-1],
              out_channels=out_channels,
              kernel_size=kernel_size,
          )
          channel_mapper(feats)
  
      channel_mapper = ChannelMapper(
          in_channels=in_channels,
          out_channels=out_channels,
          kernel_size=kernel_size,
      )
  
      outs = channel_mapper(feats)
      assert len(outs) == len(feats)
      for i in range(len(feats)):
          outs[i].shape[1] == out_channels
          outs[i].shape[2] == outs[i].shape[3] == s // (2**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 2 for calling a global function with example usage: test_channel_mapper() without return types