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.
  
  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",".","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",")"]
docstr: Initialize the weights in backbone.
  
  Args:
      pretrained (str, optional): Path to pre-trained weights.
          Defaults to None.
docstr_tok: ["Initialize","the","weights","in","backbone",".","Args",":","pretrained","(","str",",","optional",")",":","Path","to","pre-trained","weights",".","Defaults","to","None","."]
code: def init_weights(self, pretrained=None):
      """Initialize the weights in backbone.
  
      Args:
          pretrained (str, optional): Path to pre-trained weights.
              Defaults to None.
      """
      if isinstance(pretrained, str):
          logger = get_root_logger()
          load_checkpoint(self, pretrained, strict=False, logger=logger)
      elif pretrained is None:
          for m in self.modules():
              if isinstance(m, nn.Conv2d):
                  kaiming_init(m)
              elif isinstance(m, (_BatchNorm, nn.GroupNorm)):
                  constant_init(m, 1)
  
          if self.dcn is not None:
              for m in self.modules():
                  if isinstance(m, Bottleneck) and hasattr(
                      m.conv2, "conv_offset"
                  ):
                      constant_init(m.conv2.conv_offset, 0)
  
          if self.zero_init_residual:
              for m in self.modules():
                  if isinstance(m, Bottleneck):
                      constant_init(m.norm3, 0)
                  elif isinstance(m, BasicBlock):
                      constant_init(m.norm2, 0)
      else:
          raise TypeError("pretrained must be a str or None")
  
imports: import torch.nn
  import torch.utils.checkpoint
  from mmcv.cnn import build_conv_layer, build_norm_layer, build_plugin_layer, constant_init, kaiming_init
  from mmcv.runner import load_checkpoint
  from torch.nn.modules.batchnorm import _BatchNorm
  from mmdet.utils import get_root_logger
  from ..builder import BACKBONES
  from ..utils import ResLayer
label_desc: Use image node_id 7 for calling the ResNet obj's underlying member method code with example usage: obj.init_weights(pretrained) without return types