parameters: (self, in_channels, mid_channels,
                   downsample, zero_init_residual,
                   bn_statistics_group_size, name, width=1)
docstring: Initialize residual block.
  
          Args:
              in_channels (int): Number of input channels.
              mid_channels (int): Number of channels in residual branch.
              downsample (bool): Perform spatial downsampling (by a
                  factor of 2 in each spatial dimension).
              zero_init_residual (bool): Zero-initialize the scale in
                  the final batch normalization in the residual branch.
              bn_statistics_group_size (int): Group size for aggregating
                  batch normalization statistics.
              name (str): Module name.
              width (float, optional): Width growth factor for 3x3
                  convolutions.
docstring_summary: Initialize residual block.
docstring_tokens: Initialize residual block .
function: def __init__(self, in_channels, mid_channels,
                   downsample, zero_init_residual,
                   bn_statistics_group_size, name, width=1):
          """Initialize residual block.
  
          Args:
              in_channels (int): Number of input channels.
              mid_channels (int): Number of channels in residual branch.
              downsample (bool): Perform spatial downsampling (by a
                  factor of 2 in each spatial dimension).
              zero_init_residual (bool): Zero-initialize the scale in
                  the final batch normalization in the residual branch.
              bn_statistics_group_size (int): Group size for aggregating
                  batch normalization statistics.
              name (str): Module name.
              width (float, optional): Width growth factor for 3x3
                  convolutions.
  
          """
          super().__init__()
          self.name = name
          self.instance = 0
          self.out_channels = 4 * mid_channels
          # Width factor does not grow the output channel size.
          mid_channels = int(mid_channels * width)
  
          # Skip connection
          if downsample:
              self.branch1 = ConvBNRelu(self.out_channels, 1, 2, 0,
                                        False, bn_statistics_group_size,
                                        False, self.name + '_branch1')
          elif in_channels != self.out_channels:
              self.branch1 = ConvBNRelu(self.out_channels, 1, 1, 0,
                                        False, bn_statistics_group_size,
                                        False, self.name + '_branch1')
          else:
              self.branch1 = None
  
          # Residual branch
          self.branch2a = ConvBNRelu(mid_channels, 1, 1, 0,
                                     False, bn_statistics_group_size,
                                     True, self.name + '_branch2a')
          self.branch2b = ConvBNRelu(mid_channels, 3,
                                     (2 if downsample else 1), 1,
                                     False, bn_statistics_group_size,
                                     True, self.name + '_branch2b')
          self.branch2c = ConvBNRelu(self.out_channels, 1, 1, 0,
                                     zero_init_residual,
                                     bn_statistics_group_size,
                                     False, self.name + '_branch2c')
function_tokens: def __init__ ( self , in_channels , mid_channels , downsample , zero_init_residual , bn_statistics_group_size , name , width = 1 ) : super ( ) . __init__ ( ) self . name = name self . instance = 0 self . out_channels = 4 * mid_channels # Width factor does not grow the output channel size. mid_channels = int ( mid_channels * width ) # Skip connection if downsample : self . branch1 = ConvBNRelu ( self . out_channels , 1 , 2 , 0 , False , bn_statistics_group_size , False , self . name + '_branch1' ) elif in_channels != self . out_channels : self . branch1 = ConvBNRelu ( self . out_channels , 1 , 1 , 0 , False , bn_statistics_group_size , False , self . name + '_branch1' ) else : self . branch1 = None # Residual branch self . branch2a = ConvBNRelu ( mid_channels , 1 , 1 , 0 , False , bn_statistics_group_size , True , self . name + '_branch2a' ) self . branch2b = ConvBNRelu ( mid_channels , 3 , ( 2 if downsample else 1 ) , 1 , False , bn_statistics_group_size , True , self . name + '_branch2b' ) self . branch2c = ConvBNRelu ( self . out_channels , 1 , 1 , 0 , zero_init_residual , bn_statistics_group_size , False , self . name + '_branch2c' )