class_docstr: ResNet / ResNeXt / SE-ResNeXt / SE-Net
  
  This class implements all variants of ResNet, ResNeXt, SE-ResNeXt, and SENet that
    * have > 1 stride in the 3x3 conv layer of bottleneck
    * have conv-bn-act ordering
  
  This ResNet impl supports a number of stem and downsample options based on the v1c, v1d, v1e, and v1s
  variants included in the MXNet Gluon ResNetV1b model. The C and D variants are also discussed in the
  'Bag of Tricks' paper: https://arxiv.org/pdf/1812.01187. The B variant is equivalent to torchvision default.
  
  ResNet variants (the same modifications can be used in SE/ResNeXt models as well):
    * normal, b - 7x7 stem, stem_width = 64, same as torchvision ResNet, NVIDIA ResNet 'v1.5', Gluon v1b
    * c - 3 layer deep 3x3 stem, stem_width = 32 (32, 32, 64)
    * d - 3 layer deep 3x3 stem, stem_width = 32 (32, 32, 64), average pool in downsample
    * e - 3 layer deep 3x3 stem, stem_width = 64 (64, 64, 128), average pool in downsample
    * s - 3 layer deep 3x3 stem, stem_width = 64 (64, 64, 128)
    * t - 3 layer deep 3x3 stem, stem width = 32 (24, 48, 64), average pool in downsample
    * tn - 3 layer deep 3x3 stem, stem width = 32 (24, 32, 64), average pool in downsample
  
  ResNeXt
    * normal - 7x7 stem, stem_width = 64, standard cardinality and base widths
    * same c,d, e, s variants as ResNet can be enabled
  
  SE-ResNeXt
    * normal - 7x7 stem, stem_width = 64
    * same c, d, e, s variants as ResNet can be enabled
  
  SENet-154 - 3 layer deep 3x3 stem (same as v1c-v1s), stem_width = 64, cardinality=64,
      reduction by 2 on width of first bottleneck convolution, 3x3 downsample convs after first block
  
  Parameters
  ----------
  block : Block, class for the residual block. Options are BasicBlockGl, BottleneckGl.
  layers : list of int, number of layers in each block
  num_classes : int, default 1000, number of classification classes.
  in_chans : int, default 3, number of input (color) channels.
  output_stride : int, default 32, output stride of the network, 32, 16, or 8.
  global_pool : str, Global pooling type. One of 'avg', 'max', 'avgmax', 'catavgmax'
  cardinality : int, default 1, number of convolution groups for 3x3 conv in Bottleneck.
  base_width : int, default 64, factor determining bottleneck channels. `planes * base_width / 64 * cardinality`
  stem_width : int, default 64, number of channels in stem convolutions
  stem_type : str, default ''
      The type of stem:
        * '', default - a single 7x7 conv with a width of stem_width
        * 'deep' - three 3x3 convolution layers of widths stem_width, stem_width, stem_width * 2
        * 'deep_tiered' - three 3x3 conv layers of widths stem_width//4 * 3, stem_width, stem_width * 2
  block_reduce_first : int, default 1
      Reduction factor for first convolution output width of residual blocks, 1 for all archs except senets, where 2
  down_kernel_size : int, default 1, kernel size of residual block downsample path, 1x1 for most, 3x3 for senets
  avg_down : bool, default False, use average pooling for projection skip connection between stages/downsample.
  act_layer : nn.Module, activation layer
  norm_layer : nn.Module, normalization layer
  aa_layer : nn.Module, anti-aliasing layer
  drop_rate : float, default 0. Dropout probability before classifier, for training
code: def __init__(
      self,
      block,
      layers,
      num_classes=1000,
      in_chans=3,
      output_stride=32,
      global_pool="avg",
      cardinality=1,
      base_width=64,
      stem_width=64,
      stem_type="",
      replace_stem_pool=False,
      block_reduce_first=1,
      down_kernel_size=1,
      avg_down=False,
      act_layer=nn.ReLU,
      norm_layer=nn.BatchNorm2d,
      aa_layer=None,
      drop_rate=0.0,
      drop_path_rate=0.0,
      drop_block_rate=0.0,
      zero_init_last=True,
      block_args=None,
      channels=[64, 128, 256, 512],
  ):
      super(ResNet, self).__init__()
      block_args = block_args or dict()
      assert output_stride in (8, 16, 32)
      self.num_classes = num_classes
      self.drop_rate = drop_rate
      self.grad_checkpointing = False
  
      # Stem
      deep_stem = "deep" in stem_type
      inplanes = stem_width * 2 if deep_stem else 64
      if deep_stem:
          stem_chs = (stem_width, stem_width)
          if "tiered" in stem_type:
              stem_chs = (3 * (stem_width // 4), stem_width)
          self.conv1 = nn.Sequential(
              *[
                  nn.Conv2d(
                      in_chans,
                      stem_chs[0],
                      3,
                      stride=2,
                      padding=1,
                      bias=False,
                  ),
                  norm_layer(stem_chs[0]),
                  act_layer(inplace=True),
                  nn.Conv2d(
                      stem_chs[0],
                      stem_chs[1],
                      3,
                      stride=1,
                      padding=1,
                      bias=False,
                  ),
                  norm_layer(stem_chs[1]),
                  act_layer(inplace=True),
                  nn.Conv2d(
                      stem_chs[1],
                      inplanes,
                      3,
                      stride=1,
                      padding=1,
                      bias=False,
                  ),
              ]
          )
      else:
          self.conv1 = nn.Conv2d(
              in_chans,
              inplanes,
              kernel_size=7,
              stride=2,
              padding=3,
              bias=False,
          )
      self.bn1 = norm_layer(inplanes)
      self.act1 = act_layer(inplace=True)
      self.feature_info = [
          dict(num_chs=inplanes, reduction=2, module="act1")
      ]
  
      # Stem pooling. The name 'maxpool' remains for weight compatibility.
      if replace_stem_pool:
          self.maxpool = nn.Sequential(
              *filter(
                  None,
                  [
                      nn.Conv2d(
                          inplanes,
                          inplanes,
                          3,
                          stride=1 if aa_layer else 2,
                          padding=1,
                          bias=False,
                      ),
                      create_aa(aa_layer, channels=inplanes, stride=2)
                      if aa_layer is not None
                      else None,
                      norm_layer(inplanes),
                      act_layer(inplace=True),
                  ],
              )
          )
      else:
          if aa_layer is not None:
              if issubclass(aa_layer, nn.AvgPool2d):
                  self.maxpool = aa_layer(2)
              else:
                  self.maxpool = nn.Sequential(
                      *[
                          nn.MaxPool2d(
                              kernel_size=3, stride=1, padding=1
                          ),
                          aa_layer(channels=inplanes, stride=2),
                      ]
                  )
          else:
              self.maxpool = nn.MaxPool2d(
                  kernel_size=3, stride=2, padding=1
              )
  
      # Feature Blocks
      # channels = [64, 128, 256, 512]
      stage_modules, stage_feature_info = make_blocks(
          block,
          channels,
          layers,
          inplanes,
          cardinality=cardinality,
          base_width=base_width,
          output_stride=output_stride,
          reduce_first=block_reduce_first,
          avg_down=avg_down,
          down_kernel_size=down_kernel_size,
          act_layer=act_layer,
          norm_layer=norm_layer,
          aa_layer=aa_layer,
          drop_block_rate=drop_block_rate,
          drop_path_rate=drop_path_rate,
          **block_args,
      )
      for stage in stage_modules:
          self.add_module(*stage)  # layer1, layer2, etc
      self.feature_info.extend(stage_feature_info)
  
      # Head (Pooling and Classifier)
      self.num_features = 512 * block.expansion
      self.global_pool, self.fc = create_classifier(
          self.num_features, self.num_classes, pool_type=global_pool
      )
  
      self.init_weights(zero_init_last=zero_init_last)
  
imports: import math
  from functools import partial
  import torch
  import torch.nn
  import torch.nn.functional
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.models.helpers import build_model_with_cfg
  from timm.models.layers import DropBlock2d, DropPath, AvgPool2dSame, BlurPool2d, GroupNorm, create_attn, get_attn, create_classifier
label_desc: Use image node_id 1 to create a new ResNet object from inherited base classes: nn with example: obj = ResNet(block, layers, num_classes, in_chans, output_stride, global_pool, cardinality, base_width, stem_width, stem_type, replace_stem_pool, block_reduce_first, down_kernel_size, avg_down, act_layer, norm_layer, aa_layer, drop_rate, drop_path_rate, drop_block_rate, zero_init_last, block_args, channels)