docstr: Bottle2neck block for Res2Net.
  
  If style is "pytorch", the stride-two layer is the 3x3 conv layer, if
  it is "caffe", the stride-two layer is the first 1x1 conv layer.
docstr_tok: ["Bottle2neck","block","for","Res2Net",".","If","style","is","``","pytorch","''",",","the","stride-two","layer","is","the","3x3","conv","layer",",","if","it","is","``","caffe","''",",","the","stride-two","layer","is","the","first","1x1","conv","layer","."]
code: def __init__(
      self,
      inplanes,
      planes,
      scales=4,
      base_width=26,
      base_channels=64,
      stage_type="normal",
      **kwargs,
  ):
      """Bottle2neck block for Res2Net.
  
      If style is "pytorch", the stride-two layer is the 3x3 conv layer, if
      it is "caffe", the stride-two layer is the first 1x1 conv layer.
      """
      super(Bottle2neck, self).__init__(inplanes, planes, **kwargs)
      assert (
          scales > 1
      ), "Res2Net degenerates to ResNet when scales = 1."
      width = int(
          math.floor(self.planes * (base_width / base_channels))
      )
  
      self.norm1_name, norm1 = build_norm_layer(
          self.norm_cfg, width * scales, postfix=1
      )
      self.norm3_name, norm3 = build_norm_layer(
          self.norm_cfg, self.planes * self.expansion, postfix=3
      )
  
      self.conv1 = build_conv_layer(
          self.conv_cfg,
          self.inplanes,
          width * scales,
          kernel_size=1,
          stride=self.conv1_stride,
          bias=False,
      )
      self.add_module(self.norm1_name, norm1)
  
      if stage_type == "stage" and self.conv2_stride != 1:
          self.pool = nn.AvgPool2d(
              kernel_size=3, stride=self.conv2_stride, padding=1
          )
      convs = []
      bns = []
  
      fallback_on_stride = False
      if self.with_dcn:
          fallback_on_stride = self.dcn.pop("fallback_on_stride", False)
      if not self.with_dcn or fallback_on_stride:
          for i in range(scales - 1):
              convs.append(
                  build_conv_layer(
                      self.conv_cfg,
                      width,
                      width,
                      kernel_size=3,
                      stride=self.conv2_stride,
                      padding=self.dilation,
                      dilation=self.dilation,
                      bias=False,
                  )
              )
              bns.append(
                  build_norm_layer(self.norm_cfg, width, postfix=i + 1)[
                      1
                  ]
              )
          self.convs = nn.ModuleList(convs)
          self.bns = nn.ModuleList(bns)
      else:
          assert self.conv_cfg is None, "conv_cfg must be None for DCN"
          for i in range(scales - 1):
              convs.append(
                  build_conv_layer(
                      self.dcn,
                      width,
                      width,
                      kernel_size=3,
                      stride=self.conv2_stride,
                      padding=self.dilation,
                      dilation=self.dilation,
                      bias=False,
                  )
              )
              bns.append(
                  build_norm_layer(self.norm_cfg, width, postfix=i + 1)[
                      1
                  ]
              )
          self.convs = nn.ModuleList(convs)
          self.bns = nn.ModuleList(bns)
  
      self.conv3 = build_conv_layer(
          self.conv_cfg,
          width * scales,
          self.planes * self.expansion,
          kernel_size=1,
          bias=False,
      )
      self.add_module(self.norm3_name, norm3)
  
      self.stage_type = stage_type
      self.scales = scales
      self.width = width
      delattr(self, "conv2")
      delattr(self, self.norm2_name)
  
imports: import math
  import torch
  import torch.nn
  import torch.utils.checkpoint
  from mmcv.cnn import build_conv_layer, build_norm_layer
  from mmengine.model import Sequential
  from mmdet.registry import MODELS
  from .resnet import Bottleneck
  from .resnet import ResNet
label_desc: Use image node_id 1 to create a new Bottle2neck object from inherited base classes: _Bottleneck with example: obj = Bottle2neck(inplanes, planes, scales, base_width, base_channels, stage_type)