class_docstr: Residual Network, see https://arxiv.org/abs/1512.03385
  Args:
      depth (int): ResNet depth, should be 34, 50.
      freeze_at (int): freeze the backbone at which stage
      norm_type (str): normalization type, 'bn'/'sync_bn'/'affine_channel'
      freeze_norm (bool): freeze normalization layers
      norm_decay (float): weight decay for normalization layer weights
      variant (str): ResNet variant, supports 'a', 'b', 'c', 'd' currently
      feature_maps (list): index of stages whose feature maps are returned
      dcn_v2_stages (list): index of stages who select deformable conv v2
      nonlocal_stages (list): index of stages who select nonlocal networks
class_docstr_tok: ["Residual","Network",",","see","https",":","\/\/arxiv.org\/abs\/1512.03385","Args",":","depth","(","int",")",":","ResNet","depth",",","should","be","34",",","50.","freeze_at","(","int",")",":","freeze","the","backbone","at","which","stage","norm_type","(","str",")",":","normalization","type",",","'bn'\/'sync_bn'\/'affine_channel'","freeze_norm","(","bool",")",":","freeze","normalization","layers","norm_decay","(","float",")",":","weight","decay","for","normalization","layer","weights","variant","(","str",")",":","ResNet","variant",",","supports","'","a","'",",","'","b","'",",","'","c","'",",","'d","'","currently","feature_maps","(","list",")",":","index","of","stages","whose","feature","maps","are","returned","dcn_v2_stages","(","list",")",":","index","of","stages","who","select","deformable","conv","v2","nonlocal_stages","(","list",")",":","index","of","stages","who","select","nonlocal","networks"]
docstr: Args:
      input (Variable): input variable.
      stage_num (int): the stage number, should be 2, 3, 4, 5
  
  Returns:
      The last variable in endpoint-th stage.
docstr_tok: ["Args",":","input","(","Variable",")",":","input","variable",".","stage_num","(","int",")",":","the","stage","number",",","should","be","2",",","3",",","4",",","5","Returns",":","The","last","variable","in","endpoint-th","stage","."]
code: def layer_warp(self, input, stage_num):
      """
      Args:
          input (Variable): input variable.
          stage_num (int): the stage number, should be 2, 3, 4, 5
  
      Returns:
          The last variable in endpoint-th stage.
      """
      assert stage_num in [2, 3, 4, 5]
  
      stages, block_func = self.depth_cfg[self.depth]
      count = stages[stage_num - 2]
  
      ch_out = self.stage_filters[stage_num - 2]
      is_first = False if stage_num != 2 else True
      dcn_v2 = True if stage_num in self.dcn_v2_stages else False
  
      nonlocal_mod = 1000
      if stage_num in self.nonlocal_stages:
          nonlocal_mod = (
              self.nonlocal_mod_cfg[self.depth] if stage_num == 4 else 2
          )
  
      # Make the layer name and parameter name consistent
      # with ImageNet pre-trained model
      conv = input
      for i in range(count):
          conv_name = self.na.fix_layer_warp_name(stage_num, count, i)
          if self.depth < 50:
              is_first = True if i == 0 and stage_num == 2 else False
          conv = block_func(
              input=conv,
              num_filters=ch_out,
              stride=2 if i == 0 and stage_num != 2 else 1,
              is_first=is_first,
              name=conv_name,
              dcn_v2=dcn_v2,
          )
  
          # add non local model
          dim_in = conv.shape[1]
          nonlocal_name = "nonlocal_conv{}".format(stage_num)
          if i % nonlocal_mod == nonlocal_mod - 1:
              conv = add_space_nonlocal(
                  conv,
                  dim_in,
                  dim_in,
                  nonlocal_name + "_{}".format(i),
                  int(dim_in / 2),
              )
      return conv
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  from collections import OrderedDict
  from numbers import Integral
  from paddle import fluid
  from paddle.fluid.param_attr import ParamAttr
  from paddle.fluid.framework import Variable
  from paddle.fluid.regularizer import L2Decay
  from paddle.fluid.initializer import Constant
  from .nonlocal_helper import add_space_nonlocal
  from .name_adapter import NameAdapter
label_desc: Use image node_id 7 for calling the ResNet obj's underlying member method code with example usage: obj.layer_warp(input, stage_num) and returns: conv