class_docstr: ResNet backbone.
  
  Args:
      depth (int): Depth of resnet, from {18, 34, 50, 101, 152}.
      stem_channels (int | None): Number of stem channels. If not specified,
          it will be the same as `base_channels`. Default: None.
      base_channels (int): Number of base channels of res layer. Default: 64.
      in_channels (int): Number of input image channels. Default: 3.
      num_stages (int): Resnet stages. Default: 4.
      strides (Sequence[int]): Strides of the first block of each stage.
      dilations (Sequence[int]): Dilation of each stage.
      out_indices (Sequence[int]): Output from which stages.
      style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two
          layer is the 3x3 conv layer, otherwise the stride-two layer is
          the first 1x1 conv layer.
      deep_stem (bool): Replace 7x7 conv in input stem with 3 3x3 conv
      avg_down (bool): Use AvgPool instead of stride conv when
          downsampling in the bottleneck.
      frozen_stages (int): Stages to be frozen (stop grad and set eval mode).
          -1 means not freezing any parameters.
      norm_cfg (dict): Dictionary to construct and config norm layer.
      norm_eval (bool): Whether to set norm layers to eval mode, namely,
          freeze running stats (mean and var). Note: Effect on Batch Norm
          and its variants only.
      plugins (list[dict]): List of plugins for stages, each dict contains:
  
          - cfg (dict, required): Cfg dict to build plugin.
          - position (str, required): Position inside block to insert
            plugin, options are 'after_conv1', 'after_conv2', 'after_conv3'.
          - stages (tuple[bool], optional): Stages to apply plugin, length
            should be same as 'num_stages'.
      with_cp (bool): Use checkpoint or not. Using checkpoint will save some
          memory while slowing down the training speed.
      zero_init_residual (bool): Whether to use zero init for last norm layer
          in resblocks to let them behave as identity.
      pretrained (str, optional): model pretrained path. Default: None
      init_cfg (dict or list[dict], optional): Initialization config dict.
          Default: None
  
  Example:
      >>> from mmdet.models import ResNet
      >>> import torch
      >>> self = ResNet(depth=18)
      >>> self.eval()
      >>> inputs = torch.rand(1, 3, 32, 32)
      >>> level_outputs = self.forward(inputs)
      >>> for level_out in level_outputs:
      ...     print(tuple(level_out.shape))
      (1, 64, 8, 8)
      (1, 128, 4, 4)
      (1, 256, 2, 2)
      (1, 512, 1, 1)
class_docstr_tok: ["ResNet","backbone",".","Args",":","depth","(","int",")",":","Depth","of","resnet",",","from","{","18",",","34",",","50",",","101",",","152","}",".","stem_channels","(","int","|","None",")",":","Number","of","stem","channels",".","If","not","specified",",","it","will","be","the","same","as","`","base_channels","`",".","Default",":","None",".","base_channels","(","int",")",":","Number","of","base","channels","of","res","layer",".","Default",":","64.","in_channels","(","int",")",":","Number","of","input","image","channels",".","Default",":","3.","num_stages","(","int",")",":","Resnet","stages",".","Default",":","4.","strides","(","Sequence","[","int","]",")",":","Strides","of","the","first","block","of","each","stage",".","dilations","(","Sequence","[","int","]",")",":","Dilation","of","each","stage",".","out_indices","(","Sequence","[","int","]",")",":","Output","from","which","stages",".","style","(","str",")",":","`","pytorch","`","or","`","caffe","`",".","If","set","to","``","pytorch","''",",","the","stride-two","layer","is","the","3x3","conv","layer",",","otherwise","the","stride-two","layer","is","the","first","1x1","conv","layer",".","deep_stem","(","bool",")",":","Replace","7x7","conv","in","input","stem","with","3","3x3","conv","avg_down","(","bool",")",":","Use","AvgPool","instead","of","stride","conv","when","downsampling","in","the","bottleneck",".","frozen_stages","(","int",")",":","Stages","to","be","frozen","(","stop","grad","and","set","eval","mode",")",".","-1","means","not","freezing","any","parameters",".","norm_cfg","(","dict",")",":","Dictionary","to","construct","and","config","norm","layer",".","norm_eval","(","bool",")",":","Whether","to","set","norm","layers","to","eval","mode",",","namely",",","freeze","running","stats","(","mean","and","var",")",".","Note",":","Effect","on","Batch","Norm","and","its","variants","only",".","plugins","(","list","[","dict","]",")",":","List","of","plugins","for","stages",",","each","dict","contains",":","-","cfg","(","dict",",","required",")",":","Cfg","dict","to","build","plugin",".","-","position","(","str",",","required",")",":","Position","inside","block","to","insert","plugin",",","options","are","'after_conv1","'",",","'after_conv2","'",",","'after_conv3","'",".","-","stages","(","tuple","[","bool","]",",","optional",")",":","Stages","to","apply","plugin",",","length","should","be","same","as","'num_stages","'",".","with_cp","(","bool",")",":","Use","checkpoint","or","not",".","Using","checkpoint","will","save","some","memory","while","slowing","down","the","training","speed",".","zero_init_residual","(","bool",")",":","Whether","to","use","zero","init","for","last","norm","layer","in","resblocks","to","let","them","behave","as","identity",".","pretrained","(","str",",","optional",")",":","model","pretrained","path",".","Default",":","None","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict",".","Default",":","None","Example",":",">",">",">","from","mmdet.models","import","ResNet",">",">",">","import","torch",">",">",">","self","=","ResNet","(","depth=18",")",">",">",">","self.eval","(",")",">",">",">","inputs","=","torch.rand","(","1",",","3",",","32",",","32",")",">",">",">","level_outputs","=","self.forward","(","inputs",")",">",">",">","for","level_out","in","level_outputs",":","...","print","(","tuple","(","level_out.shape",")",")","(","1",",","64",",","8",",","8",")","(","1",",","128",",","4",",","4",")","(","1",",","256",",","2",",","2",")","(","1",",","512",",","1",",","1",")"]
code: def _make_stem_layer(self, in_channels, stem_channels):
      if self.deep_stem:
          self.stem = nn.Sequential(
              build_conv_layer(
                  self.conv_cfg,
                  in_channels,
                  stem_channels // 2,
                  kernel_size=3,
                  stride=2,
                  padding=1,
                  bias=False,
              ),
              build_norm_layer(self.norm_cfg, stem_channels // 2)[1],
              nn.ReLU(inplace=True),
              build_conv_layer(
                  self.conv_cfg,
                  stem_channels // 2,
                  stem_channels // 2,
                  kernel_size=3,
                  stride=1,
                  padding=1,
                  bias=False,
              ),
              build_norm_layer(self.norm_cfg, stem_channels // 2)[1],
              nn.ReLU(inplace=True),
              build_conv_layer(
                  self.conv_cfg,
                  stem_channels // 2,
                  stem_channels,
                  kernel_size=3,
                  stride=1,
                  padding=1,
                  bias=False,
              ),
              build_norm_layer(self.norm_cfg, stem_channels)[1],
              nn.ReLU(inplace=True),
          )
      else:
          self.conv1 = build_conv_layer(
              self.conv_cfg,
              in_channels,
              stem_channels,
              kernel_size=7,
              stride=2,
              padding=3,
              bias=False,
          )
          self.norm1_name, norm1 = build_norm_layer(
              self.norm_cfg, stem_channels, postfix=1
          )
          self.add_module(self.norm1_name, norm1)
          self.relu = nn.ReLU(inplace=True)
      self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
  
imports: import warnings
  import torch.nn
  import torch.utils.checkpoint
  from mmcv.cnn import build_conv_layer, build_norm_layer, build_plugin_layer
  from mmengine.model import BaseModule
  from torch.nn.modules.batchnorm import _BatchNorm
  from mmdet.registry import MODELS
  from ..layers import ResLayer
label_desc: Use image node_id 5 for calling the ResNet obj's underlying member method code with example usage: obj._make_stem_layer(in_channels, stem_channels) without return types