class_docstr: The basic residual block for ResNet-18 and ResNet-34 defined in :paper:`ResNet`,
  with two 3x3 conv layers and a projection shortcut if needed.
class_docstr_tok: ["The","basic","residual","block","for","ResNet-18","and","ResNet-34","defined","in",":","paper",":","`","ResNet","`",",","with","two","3x3","conv","layers","and","a","projection","shortcut","if","needed","."]
docstr: Args:
      in_channels (int): Number of input channels.
      out_channels (int): Number of output channels.
      stride (int): Stride for the first conv.
      norm (str or callable): normalization for all conv layers.
          See :func:`layers.get_norm` for supported format.
docstr_tok: ["Args",":","in_channels","(","int",")",":","Number","of","input","channels",".","out_channels","(","int",")",":","Number","of","output","channels",".","stride","(","int",")",":","Stride","for","the","first","conv",".","norm","(","str","or","callable",")",":","normalization","for","all","conv","layers",".","See",":","func",":","`","layers.get_norm","`","for","supported","format","."]
code: def __init__(self, in_channels, out_channels, *, stride=1, norm="BN"):
      """
      Args:
          in_channels (int): Number of input channels.
          out_channels (int): Number of output channels.
          stride (int): Stride for the first conv.
          norm (str or callable): normalization for all conv layers.
              See :func:`layers.get_norm` for supported format.
      """
      super().__init__(in_channels, out_channels, stride)
  
      if in_channels != out_channels:
          self.shortcut = Conv2d(
              in_channels,
              out_channels,
              kernel_size=1,
              stride=stride,
              bias=False,
              norm=get_norm(norm, out_channels),
          )
      else:
          self.shortcut = None
  
      self.conv1 = Conv2d(
          in_channels,
          out_channels,
          kernel_size=3,
          stride=stride,
          padding=1,
          bias=False,
          norm=get_norm(norm, out_channels),
      )
  
      self.conv2 = Conv2d(
          out_channels,
          out_channels,
          kernel_size=3,
          stride=1,
          padding=1,
          bias=False,
          norm=get_norm(norm, out_channels),
      )
  
      for layer in [self.conv1, self.conv2, self.shortcut]:
          if layer is not None:  # shortcut can be None
              weight_init.c2_msra_fill(layer)
  
imports: import numpy
  import fvcore.nn.weight_init
  import torch
  import torch.nn.functional
  from torch import nn
  from detectron2.layers import CNNBlockBase, Conv2d, DeformConv, ModulatedDeformConv, ShapeSpec, get_norm
  from .backbone import Backbone
  from .build import BACKBONE_REGISTRY
label_desc: Use image node_id 1 to create a new BasicBlock object from inherited base classes: CNNBlockBase with example: obj = BasicBlock(in_channels, out_channels)