code: def test_resnet_res_layer():
      # Test ResLayer of 3 Bottleneck w\o downsample
      layer = ResLayer(Bottleneck, 64, 16, 3)
      assert len(layer) == 3
      assert layer[0].conv1.in_channels == 64
      assert layer[0].conv1.out_channels == 16
      for i in range(1, len(layer)):
          assert layer[i].conv1.in_channels == 64
          assert layer[i].conv1.out_channels == 16
      for i in range(len(layer)):
          assert layer[i].downsample is None
      x = torch.randn(1, 64, 56, 56)
      x_out = layer(x)
      assert x_out.shape == torch.Size([1, 64, 56, 56])
  
      # Test ResLayer of 3 Bottleneck with downsample
      layer = ResLayer(Bottleneck, 64, 64, 3)
      assert layer[0].downsample[0].out_channels == 256
      for i in range(1, len(layer)):
          assert layer[i].downsample is None
      x = torch.randn(1, 64, 56, 56)
      x_out = layer(x)
      assert x_out.shape == torch.Size([1, 256, 56, 56])
  
      # Test ResLayer of 3 Bottleneck with stride=2
      layer = ResLayer(Bottleneck, 64, 64, 3, stride=2)
      assert layer[0].downsample[0].out_channels == 256
      assert layer[0].downsample[0].stride == (2, 2)
      for i in range(1, len(layer)):
          assert layer[i].downsample is None
      x = torch.randn(1, 64, 56, 56)
      x_out = layer(x)
      assert x_out.shape == torch.Size([1, 256, 28, 28])
  
      # Test ResLayer of 3 Bottleneck with stride=2 and average downsample
      layer = ResLayer(Bottleneck, 64, 64, 3, stride=2, avg_down=True)
      assert isinstance(layer[0].downsample[0], AvgPool2d)
      assert layer[0].downsample[1].out_channels == 256
      assert layer[0].downsample[1].stride == (1, 1)
      for i in range(1, len(layer)):
          assert layer[i].downsample is None
      x = torch.randn(1, 64, 56, 56)
      x_out = layer(x)
      assert x_out.shape == torch.Size([1, 256, 28, 28])
  
      # Test ResLayer of 3 BasicBlock with stride=2 and downsample_first=False
      layer = ResLayer(
          BasicBlock, 64, 64, 3, stride=2, downsample_first=False
      )
      assert layer[2].downsample[0].out_channels == 64
      assert layer[2].downsample[0].stride == (2, 2)
      for i in range(len(layer) - 1):
          assert layer[i].downsample is None
      x = torch.randn(1, 64, 56, 56)
      x_out = layer(x)
      assert x_out.shape == torch.Size([1, 64, 28, 28])
  
file_path: mmdetection/tests/test_models/test_backbones/test_resnet.py
imports: import pytest
  import torch
  from mmcv.ops import DeformConv2dPack
  from torch.nn.modules import AvgPool2d, GroupNorm
  from torch.nn.modules.batchnorm import _BatchNorm
  from mmdet.models.backbones import ResNet, ResNetV1d
  from mmdet.models.backbones.resnet import BasicBlock, Bottleneck
  from mmdet.models.layers import ResLayer, SimplifiedBasicBlock
  from .utils import check_norm_state, is_block, is_norm
label_desc: Use image node_id 5 for calling a global function with example usage: test_resnet_res_layer() without return types