code: def __init__(
      self,
      layers=50,
      lr_mult=1.0,
      last_conv_stride=2,
      last_conv_dilation=1,
  ):
      super(ResNet, self).__init__()
      self.layers = layers
      self.data_format = "NCHW"
      self.input_image_channel = 3
      supported_layers = [18, 34, 50, 101, 152]
      assert (
          layers in supported_layers
      ), "supported layers are {} but input layer is {}".format(
          supported_layers, layers
      )
      if layers == 18:
          depth = [2, 2, 2, 2]
      elif layers == 34 or layers == 50:
          depth = [3, 4, 6, 3]
      elif layers == 101:
          depth = [3, 4, 23, 3]
      elif layers == 152:
          depth = [3, 8, 36, 3]
      num_channels = (
          [64, 256, 512, 1024] if layers >= 50 else [64, 64, 128, 256]
      )
      num_filters = [64, 128, 256, 512]
      self.conv = ConvBNLayer(
          num_channels=self.input_image_channel,
          num_filters=64,
          filter_size=7,
          stride=2,
          act="relu",
          lr_mult=lr_mult,
          name="conv1",
          data_format=self.data_format,
      )
      self.pool2d_max = nn.MaxPool2D(
          kernel_size=3,
          stride=2,
          padding=1,
          data_format=self.data_format,
      )
      self.block_list = []
      if layers >= 50:
          for block in range(len(depth)):
              shortcut = False
              for i in range(depth[block]):
                  if layers in [101, 152] and block == 2:
                      if i == 0:
                          conv_name = "res" + str(block + 2) + "a"
                      else:
                          conv_name = (
                              "res" + str(block + 2) + "b" + str(i)
                          )
                  else:
                      conv_name = "res" + str(block + 2) + chr(97 + i)
                  if i != 0 or block == 0:
                      stride = 1
                  elif block == len(depth) - 1:
                      stride = last_conv_stride
                  else:
                      stride = 2
                  bottleneck_block = self.add_sublayer(
                      conv_name,
                      BottleneckBlock(
                          num_channels=num_channels[block]
                          if i == 0
                          else num_filters[block] * 4,
                          num_filters=num_filters[block],
                          stride=stride,
                          shortcut=shortcut,
                          name=conv_name,
                          lr_mult=lr_mult,
                          dilation=last_conv_dilation
                          if block == len(depth) - 1
                          else 1,
                          data_format=self.data_format,
                      ),
                  )
                  self.block_list.append(bottleneck_block)
                  shortcut = True
      else:
          for block in range(len(depth)):
              shortcut = False
              for i in range(depth[block]):
                  conv_name = "res" + str(block + 2) + chr(97 + i)
                  basic_block = self.add_sublayer(
                      conv_name,
                      BasicBlock(
                          num_channels=num_channels[block]
                          if i == 0
                          else num_filters[block],
                          num_filters=num_filters[block],
                          stride=2 if i == 0 and block != 0 else 1,
                          shortcut=shortcut,
                          name=conv_name,
                          data_format=self.data_format,
                      ),
                  )
                  self.block_list.append(basic_block)
                  shortcut = True
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import math
  import paddle
  from paddle import ParamAttr
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn.initializer import Normal
label_desc: Use image node_id 1 to create a new ResNet object from inherited base classes: nn with example: obj = ResNet(layers, lr_mult, last_conv_stride, last_conv_dilation)