class_docstr: Identity Residual Block for WideResnet
docstr: Configurable identity-mapping residual block
  
  Parameters
  ----------
  in_channels : int
      Number of input channels.
  channels : list of int
      Number of channels in the internal feature maps.
      Can either have two or three elements: if three construct
      a residual block with two `3 x 3` convolutions,
      otherwise construct a bottleneck block with `1 x 1`, then
      `3 x 3` then `1 x 1` convolutions.
  stride : int
      Stride of the first `3 x 3` convolution
  dilation : int
      Dilation to apply to the `3 x 3` convolutions.
  groups : int
      Number of convolution groups.
      This is used to create ResNeXt-style blocks and is only compatible with
      bottleneck blocks.
  norm_act : callable
      Function to create normalization / activation Module.
  dropout: callable
      Function to create Dropout Module.
  dist_bn: Boolean
      A variable to enable or disable use of distributed BN
docstr_tok: ["Configurable","identity-mapping","residual","block","Parameters","--","--","--","--","--","in_channels",":","int","Number","of","input","channels",".","channels",":","list","of","int","Number","of","channels","in","the","internal","feature","maps",".","Can","either","have","two","or","three","elements",":","if","three","construct","a","residual","block","with","two","`","3","x","3","`","convolutions",",","otherwise","construct","a","bottleneck","block","with","`","1","x","1","`",",","then","`","3","x","3","`","then","`","1","x","1","`","convolutions",".","stride",":","int","Stride","of","the","first","`","3","x","3","`","convolution","dilation",":","int","Dilation","to","apply","to","the","`","3","x","3","`","convolutions",".","groups",":","int","Number","of","convolution","groups",".","This","is","used","to","create","ResNeXt-style","blocks","and","is","only","compatible","with","bottleneck","blocks",".","norm_act",":","callable","Function","to","create","normalization","\/","activation","Module",".","dropout",":","callable","Function","to","create","Dropout","Module",".","dist_bn",":","Boolean","A","variable","to","enable","or","disable","use","of","distributed","BN"]
code: def __init__(
      self,
      in_channels,
      channels,
      strides=1,
      dilation=1,
      groups=1,
      norm_act=bnrelu,
      dropout=None,
      dist_bn=False,
  ):
      """Configurable identity-mapping residual block
  
      Parameters
      ----------
      in_channels : int
          Number of input channels.
      channels : list of int
          Number of channels in the internal feature maps.
          Can either have two or three elements: if three construct
          a residual block with two `3 x 3` convolutions,
          otherwise construct a bottleneck block with `1 x 1`, then
          `3 x 3` then `1 x 1` convolutions.
      stride : int
          Stride of the first `3 x 3` convolution
      dilation : int
          Dilation to apply to the `3 x 3` convolutions.
      groups : int
          Number of convolution groups.
          This is used to create ResNeXt-style blocks and is only compatible with
          bottleneck blocks.
      norm_act : callable
          Function to create normalization / activation Module.
      dropout: callable
          Function to create Dropout Module.
      dist_bn: Boolean
          A variable to enable or disable use of distributed BN
      """
      super(IdentityResidualBlock, self).__init__()
      self.dist_bn = dist_bn
  
      # Check parameters for inconsistencies
      if len(channels) != 2 and len(channels) != 3:
          raise ValueError(
              "channels must contain either two or three values"
          )
      if len(channels) == 2 and groups != 1:
          raise ValueError(
              "groups > 1 are only valid if len(channels) == 3"
          )
  
      is_bottleneck = len(channels) == 3
      need_proj_conv = strides != 1 or in_channels != channels[-1]
  
      self.bn1 = norm_act(in_channels)
      if not is_bottleneck:
          layers = [
              (
                  "conv1",
                  nn.Conv2D(
                      in_channels=in_channels,
                      channels=channels[0],
                      kernel_size=3,
                      strides=strides,
                      padding=dilation,
                      use_bias=False,
                      dilation=dilation,
                  ),
              ),
              ("bn2", norm_act(channels[0])),
              (
                  "conv2",
                  nn.Conv2D(
                      in_channels=channels[0],
                      channels=channels[1],
                      kernel_size=3,
                      strides=1,
                      padding=dilation,
                      use_bias=False,
                      dilation=dilation,
                  ),
              ),
          ]
          if dropout is not None:
              layers = (
                  layers[0:2] + [("dropout", dropout())] + layers[2:]
              )
      else:
          layers = [
              (
                  "conv1",
                  nn.Conv2D(
                      in_channels=in_channels,
                      channels=channels[0],
                      kernel_size=1,
                      strides=strides,
                      padding=0,
                      use_bias=False,
                  ),
              ),
              ("bn2", norm_act(channels[0])),
              (
                  "conv2",
                  nn.Conv2D(
                      in_channels=channels[0],
                      channels=channels[1],
                      kernel_size=3,
                      strides=1,
                      padding=dilation,
                      use_bias=False,
                      groups=groups,
                      dilation=dilation,
                  ),
              ),
              ("bn3", norm_act(channels[1])),
              (
                  "conv3",
                  nn.Conv2D(
                      in_channels=channels[1],
                      channels=channels[2],
                      kernel_size=1,
                      strides=1,
                      padding=0,
                      use_bias=False,
                  ),
              ),
          ]
          if dropout is not None:
              layers = (
                  layers[0:4] + [("dropout", dropout())] + layers[4:]
              )
  
      layer_dict = OrderedDict(layers)
      self.convs = nn.HybridSequential(prefix="")
      for key in layer_dict.keys():
          self.convs.add(layer_dict[key])
  
      if need_proj_conv:
          self.proj_conv = nn.Conv2D(
              in_channels=in_channels,
              channels=channels[-1],
              kernel_size=1,
              strides=strides,
              padding=0,
              use_bias=False,
          )
  
file_path: gluon-cv/gluoncv/model_zoo/wideresnet.py
imports: import sys
  from collections import OrderedDict
  from functools import partial
  from mxnet.gluon import nn
  from mxnet.gluon.nn import HybridBlock
label_desc: Use image node_id 1 to create a new IdentityResidualBlock object from inherited base classes: HybridBlock with example: obj = IdentityResidualBlock(in_channels, channels, strides, dilation, groups, norm_act, dropout, dist_bn)