class_docstr: Pre-trained ResNetV1b Model, which produces the strides of 8 featuremaps at conv5.
  
  Parameters
  ----------
  block : Block
      Class for the residual block. Options are BasicBlockV1, BottleneckV1.
  layers : list of int
      Numbers of layers in each block
  classes : int, default 1000
      Number of classification classes.
  dilated : bool, default False
      Applying dilation strategy to pretrained ResNet yielding a stride-8 model,
      typically used in Semantic Segmentation.
  norm_layer : object
      Normalization layer used (default: :class:`nn.BatchNorm2d`)
  deep_stem : bool, default False
      Whether to replace the 7x7 conv1 with 3 3x3 convolution layers.
  avg_down : bool, default False
      Whether to use average pooling for projection skip connection between stages/downsample.
  final_drop : float, default 0.0
      Dropout ratio before the final classification layer.
  
  Reference:
      - He, Kaiming, et al. "Deep residual learning for image recognition."
      Proceedings of the IEEE conference on computer vision and pattern recognition. 2016.
  
      - Yu, Fisher, and Vladlen Koltun. "Multi-scale context aggregation by dilated convolutions."
class_docstr_tok: ["Pre-trained","ResNetV1b","Model",",","which","produces","the","strides","of","8","featuremaps","at","conv5",".","Parameters","--","--","--","--","--","block",":","Block","Class","for","the","residual","block",".","Options","are","BasicBlockV1",",","BottleneckV1",".","layers",":","list","of","int","Numbers","of","layers","in","each","block","classes",":","int",",","default","1000","Number","of","classification","classes",".","dilated",":","bool",",","default","False","Applying","dilation","strategy","to","pretrained","ResNet","yielding","a","stride-8","model",",","typically","used","in","Semantic","Segmentation",".","norm_layer",":","object","Normalization","layer","used","(","default",":",":","class",":","`","nn.BatchNorm2d","`",")","deep_stem",":","bool",",","default","False","Whether","to","replace","the","7x7","conv1","with","3","3x3","convolution","layers",".","avg_down",":","bool",",","default","False","Whether","to","use","average","pooling","for","projection","skip","connection","between","stages\/downsample",".","final_drop",":","float",",","default","0.0","Dropout","ratio","before","the","final","classification","layer",".","Reference",":","-","He",",","Kaiming",",","et","al",".","``","Deep","residual","learning","for","image","recognition",".","''","Proceedings","of","the","IEEE","conference","on","computer","vision","and","pattern","recognition",".","2016",".","-","Yu",",","Fisher",",","and","Vladlen","Koltun",".","``","Multi-scale","context","aggregation","by","dilated","convolutions",".","''"]
code: def _make_layer(
      self,
      block,
      planes,
      blocks,
      stride=1,
      dilation=1,
      avg_down=False,
      norm_layer=nn.BatchNorm2d,
  ):
      downsample = None
      if stride != 1 or self.inplanes != planes * block.expansion:
          downsample = []
          if avg_down:
              if dilation == 1:
                  downsample.append(
                      nn.AvgPool2d(
                          kernel_size=stride,
                          stride=stride,
                          ceil_mode=True,
                          count_include_pad=False,
                      )
                  )
              else:
                  downsample.append(
                      nn.AvgPool2d(
                          kernel_size=1,
                          stride=1,
                          ceil_mode=True,
                          count_include_pad=False,
                      )
                  )
              downsample.extend(
                  [
                      nn.Conv2d(
                          self.inplanes,
                          out_channels=planes * block.expansion,
                          kernel_size=1,
                          stride=1,
                          bias=False,
                      ),
                      norm_layer(planes * block.expansion),
                  ]
              )
              downsample = nn.Sequential(*downsample)
          else:
              downsample = nn.Sequential(
                  nn.Conv2d(
                      self.inplanes,
                      out_channels=planes * block.expansion,
                      kernel_size=1,
                      stride=stride,
                      bias=False,
                  ),
                  norm_layer(planes * block.expansion),
              )
  
      layers = []
      if dilation in (1, 2):
          layers.append(
              block(
                  self.inplanes,
                  planes,
                  stride,
                  dilation=1,
                  downsample=downsample,
                  previous_dilation=dilation,
                  norm_layer=norm_layer,
              )
          )
      elif dilation == 4:
          layers.append(
              block(
                  self.inplanes,
                  planes,
                  stride,
                  dilation=2,
                  downsample=downsample,
                  previous_dilation=dilation,
                  norm_layer=norm_layer,
              )
          )
      else:
          raise RuntimeError(
              "=> unknown dilation size: {}".format(dilation)
          )
  
      self.inplanes = planes * block.expansion
      for _ in range(1, blocks):
          layers.append(
              block(
                  self.inplanes,
                  planes,
                  dilation=dilation,
                  previous_dilation=dilation,
                  norm_layer=norm_layer,
              )
          )
  
      return nn.Sequential(*layers)
  
file_path: carefree-learn/cflearn/api/cv/third_party/iharm/model/modeling/resnetv1b.py
imports: import torch
  import torch.nn
label_desc: Use image node_id 2 for calling the ResNetV1b obj's underlying member method code with example usage: obj._make_layer(block, planes, blocks, stride, dilation, avg_down, norm_layer) and returns: nn