class_docstr: ResNet Stage.
class_docstr_tok: ["ResNet","Stage","."]
code: def __init__(
      self,
      in_chs,
      out_chs,
      stride,
      dilation,
      depth,
      bottle_ratio=0.25,
      groups=1,
      avg_down=False,
      block_dpr=None,
      block_fn=PreActBottleneck,
      act_layer=None,
      conv_layer=None,
      norm_layer=None,
      **block_kwargs,
  ):
      super(ResNetStage, self).__init__()
      first_dilation = 1 if dilation in (1, 2) else 2
      layer_kwargs = dict(
          act_layer=act_layer,
          conv_layer=conv_layer,
          norm_layer=norm_layer,
      )
      proj_layer = DownsampleAvg if avg_down else DownsampleConv
      prev_chs = in_chs
      self.blocks = nn.Sequential()
      for block_idx in range(depth):
          drop_path_rate = block_dpr[block_idx] if block_dpr else 0.0
          stride = stride if block_idx == 0 else 1
          self.blocks.add_module(
              str(block_idx),
              block_fn(
                  prev_chs,
                  out_chs,
                  stride=stride,
                  dilation=dilation,
                  bottle_ratio=bottle_ratio,
                  groups=groups,
                  first_dilation=first_dilation,
                  proj_layer=proj_layer,
                  drop_path_rate=drop_path_rate,
                  **layer_kwargs,
                  **block_kwargs,
              ),
          )
          prev_chs = out_chs
          first_dilation = dilation
          proj_layer = None
  
imports: from collections import OrderedDict
  from functools import partial
  import torch
  import torch.nn
  from timm.data import IMAGENET_INCEPTION_MEAN, IMAGENET_INCEPTION_STD
  from timm.layers import GroupNormAct, BatchNormAct2d, EvoNorm2dS0, FilterResponseNormTlu2d, ClassifierHead, DropPath, AvgPool2dSame, create_pool2d, StdConv2d, create_conv2d, get_act_layer, get_norm_act_layer, make_divisible
  from ._builder import build_model_with_cfg
  from ._manipulate import checkpoint_seq, named_apply, adapt_input_conv
  from ._registry import generate_default_cfgs, register_model, register_model_deprecations
label_desc: Use image node_id 1 to create a new ResNetStage object from inherited base classes: nn with example: obj = ResNetStage(in_chs, out_chs, stride, dilation, depth, bottle_ratio, groups, avg_down, block_dpr, block_fn, act_layer, conv_layer, norm_layer)