class_docstr: The HRFormer implementation based on PaddlePaddle.
  
  The original article refers to
  Jingdong Wang, et, al. "HRNet：Deep High-Resolution Representation Learning for Visual Recognition"
  (https://arxiv.org/pdf/1908.07919.pdf).
  
  Args:
      drop_path_rate (float, optional): The rate of Drop Path. Default: 0.2.
      stage1_num_blocks (list[int], optional): Number of blocks per module for stage1. Default: [2].
      stage1_num_channels (list[int], optional): Number of channels per branch for stage1. Default: [64].
      stage2_num_modules (int, optional): Number of modules for stage2. Default: 1.
      stage2_num_branches (int, optional): Number of branches for stage2. Default: 2.
      stage2_num_blocks (list[int], optional): Number of blocks per module for stage2. Default: [2, 2].
      stage2_num_channels (list[int], optional): Number of channels per branch for stage2. Default: [32, 64].
      stage2_num_heads (list[int], optional): Number of heads per multi head attetion for stage2. Default: [1, 2].
      stage2_num_mlp_ratios (list[int], optional): Number of ratio of mlp per multi head attetion for stage2. Default: [4, 4].
      stage2_num_window_sizes (list[int], optional): Number of window sizes for stage2. Default: [7, 7].
      stage3_num_modules (int, optional): Number of modules for stage3. Default: 4.
      stage3_num_branches (int, optional): Number of branches for stage3. Default: 3.
      stage3_num_blocks (list[int], optional): Number of blocks per module for stage3. Default: [2, 2, 2].
      stage3_num_channels (list[int], optional): Number of channels per branch for stage3. Default: [32, 64, 128].
      stage3_num_heads (list[int], optional): Number of heads per multi head attetion for stage3. Default: [1, 2, 4].
      stage3_num_mlp_ratios (list[int], optional): Number of ratio of mlp per multi head attetion for stage3. Default: [4, 4, 4].
      stage3_num_window_sizes (list[int], optional): Number of window sizes for stage3. Default: [7, 7, 7].
      stage4_num_modules (int, optional): Number of modules for stage4. Default: 2.
      stage4_num_branches (int, optional): Number of branches for stage4. Default: 4.
      stage4_num_blocks (list[int], optional): Number of blocks per module for stage4. Default: [2, 2, 2, 2].
      stage4_num_channels (list[int], optional): Number of channels per branch for stage4. Default: [32, 64, 128, 256].
      stage4_num_heads (list[int], optional): Number of heads per multi head attetion for stage4. Default: [1, 2, 4, 8].
      stage4_num_mlp_ratios (list[int], optional): Number of ratio of mlp per multi head attetion for stage4. Default: [4, 4, 4, 4].
      stage4_num_window_sizes (list[int], optional): Number of window sizes for stage4. Default: [7, 7, 7, 7].
      in_channels (int, optional): The channels of input image. Default: 3.
      pretrained (str, optional): The path of pretrained model. Default: None.
class_docstr_tok: ["The","HRFormer","implementation","based","on","PaddlePaddle",".","The","original","article","refers","to","Jingdong","Wang",",","et",",","al",".","``","HRNet\uff1aDeep","High-Resolution","Representation","Learning","for","Visual","Recognition","''","(","https",":","\/\/arxiv.org\/pdf\/1908.07919.pdf",")",".","Args",":","drop_path_rate","(","float",",","optional",")",":","The","rate","of","Drop","Path",".","Default",":","0.2.","stage1_num_blocks","(","list","[","int","]",",","optional",")",":","Number","of","blocks","per","module","for","stage1",".","Default",":","[","2","]",".","stage1_num_channels","(","list","[","int","]",",","optional",")",":","Number","of","channels","per","branch","for","stage1",".","Default",":","[","64","]",".","stage2_num_modules","(","int",",","optional",")",":","Number","of","modules","for","stage2",".","Default",":","1.","stage2_num_branches","(","int",",","optional",")",":","Number","of","branches","for","stage2",".","Default",":","2.","stage2_num_blocks","(","list","[","int","]",",","optional",")",":","Number","of","blocks","per","module","for","stage2",".","Default",":","[","2",",","2","]",".","stage2_num_channels","(","list","[","int","]",",","optional",")",":","Number","of","channels","per","branch","for","stage2",".","Default",":","[","32",",","64","]",".","stage2_num_heads","(","list","[","int","]",",","optional",")",":","Number","of","heads","per","multi","head","attetion","for","stage2",".","Default",":","[","1",",","2","]",".","stage2_num_mlp_ratios","(","list","[","int","]",",","optional",")",":","Number","of","ratio","of","mlp","per","multi","head","attetion","for","stage2",".","Default",":","[","4",",","4","]",".","stage2_num_window_sizes","(","list","[","int","]",",","optional",")",":","Number","of","window","sizes","for","stage2",".","Default",":","[","7",",","7","]",".","stage3_num_modules","(","int",",","optional",")",":","Number","of","modules","for","stage3",".","Default",":","4.","stage3_num_branches","(","int",",","optional",")",":","Number","of","branches","for","stage3",".","Default",":","3.","stage3_num_blocks","(","list","[","int","]",",","optional",")",":","Number","of","blocks","per","module","for","stage3",".","Default",":","[","2",",","2",",","2","]",".","stage3_num_channels","(","list","[","int","]",",","optional",")",":","Number","of","channels","per","branch","for","stage3",".","Default",":","[","32",",","64",",","128","]",".","stage3_num_heads","(","list","[","int","]",",","optional",")",":","Number","of","heads","per","multi","head","attetion","for","stage3",".","Default",":","[","1",",","2",",","4","]",".","stage3_num_mlp_ratios","(","list","[","int","]",",","optional",")",":","Number","of","ratio","of","mlp","per","multi","head","attetion","for","stage3",".","Default",":","[","4",",","4",",","4","]",".","stage3_num_window_sizes","(","list","[","int","]",",","optional",")",":","Number","of","window","sizes","for","stage3",".","Default",":","[","7",",","7",",","7","]",".","stage4_num_modules","(","int",",","optional",")",":","Number","of","modules","for","stage4",".","Default",":","2.","stage4_num_branches","(","int",",","optional",")",":","Number","of","branches","for","stage4",".","Default",":","4.","stage4_num_blocks","(","list","[","int","]",",","optional",")",":","Number","of","blocks","per","module","for","stage4",".","Default",":","[","2",",","2",",","2",",","2","]",".","stage4_num_channels","(","list","[","int","]",",","optional",")",":","Number","of","channels","per","branch","for","stage4",".","Default",":","[","32",",","64",",","128",",","256","]",".","stage4_num_heads","(","list","[","int","]",",","optional",")",":","Number","of","heads","per","multi","head","attetion","for","stage4",".","Default",":","[","1",",","2",",","4",",","8","]",".","stage4_num_mlp_ratios","(","list","[","int","]",",","optional",")",":","Number","of","ratio","of","mlp","per","multi","head","attetion","for","stage4",".","Default",":","[","4",",","4",",","4",",","4","]",".","stage4_num_window_sizes","(","list","[","int","]",",","optional",")",":","Number","of","window","sizes","for","stage4",".","Default",":","[","7",",","7",",","7",",","7","]",".","in_channels","(","int",",","optional",")",":","The","channels","of","input","image",".","Default",":","3.","pretrained","(","str",",","optional",")",":","The","path","of","pretrained","model",".","Default",":","None","."]
code: def __init__(
      self,
      drop_path_rate=0.2,
      stage1_num_blocks=[2],
      stage1_num_channels=[64],
      stage2_num_modules=1,
      stage2_num_branches=2,
      stage2_num_blocks=[2, 2],
      stage2_num_channels=[32, 64],
      stage2_num_heads=[1, 2],
      stage2_num_mlp_ratios=[4, 4],
      stage2_num_window_sizes=[7, 7],
      stage3_num_modules=4,
      stage3_num_branches=3,
      stage3_num_blocks=[2, 2, 2],
      stage3_num_channels=[32, 64, 128],
      stage3_num_heads=[1, 2, 4],
      stage3_num_mlp_ratios=[4, 4, 4],
      stage3_num_window_sizes=[7, 7, 7],
      stage4_num_modules=2,
      stage4_num_branches=4,
      stage4_num_blocks=[2, 2, 2, 2],
      stage4_num_channels=[32, 64, 128, 256],
      stage4_num_heads=[1, 2, 4, 8],
      stage4_num_mlp_ratios=[4, 4, 4, 4],
      stage4_num_window_sizes=[7, 7, 7, 7],
      in_channels=3,
      pretrained=None,
  ):
      super(HighResolutionTransformer, self).__init__()
  
      self.pretrained = pretrained
      self.drop_path_rate = drop_path_rate
      self.stage1_num_blocks = stage1_num_blocks
      self.stage1_num_channels = stage1_num_channels
      self.stage2_num_modules = stage2_num_modules
      self.stage2_num_branches = stage2_num_branches
      self.stage2_num_blocks = stage2_num_blocks
      self.stage2_num_channels = stage2_num_channels
      self.stage2_num_heads = stage2_num_heads
      self.stage2_num_mlp_ratios = stage2_num_mlp_ratios
      self.stage2_num_window_sizes = stage2_num_window_sizes
      self.stage3_num_modules = stage3_num_modules
      self.stage3_num_branches = stage3_num_branches
      self.stage3_num_blocks = stage3_num_blocks
      self.stage3_num_channels = stage3_num_channels
      self.stage3_num_heads = stage3_num_heads
      self.stage3_num_mlp_ratios = stage3_num_mlp_ratios
      self.stage3_num_window_sizes = stage3_num_window_sizes
      self.stage4_num_modules = stage4_num_modules
      self.stage4_num_branches = stage4_num_branches
      self.stage4_num_blocks = stage4_num_blocks
      self.stage4_num_channels = stage4_num_channels
      self.stage4_num_heads = stage4_num_heads
      self.stage4_num_mlp_ratios = stage4_num_mlp_ratios
      self.stage4_num_window_sizes = stage4_num_window_sizes
  
      self.conv1 = layers.ConvBNReLU(
          in_channels,
          64,
          kernel_size=3,
          stride=2,
          padding=1,
          bias_attr=False,
      )
  
      self.conv2 = layers.ConvBNReLU(
          64, 64, kernel_size=3, stride=2, padding=1, bias_attr=False
      )
  
      self.feat_channels = [sum(self.stage4_num_channels)]
  
      depth_s2 = self.stage2_num_blocks[0] * self.stage2_num_modules
      depth_s3 = self.stage3_num_blocks[0] * self.stage3_num_modules
      depth_s4 = self.stage4_num_blocks[0] * self.stage4_num_modules
      depths = [depth_s2, depth_s3, depth_s4]
      drop_path_rate = self.drop_path_rate
  
      dpr = [
          x.item()
          for x in paddle.linspace(0, drop_path_rate, sum(depths))
      ]
  
      num_channels = self.stage1_num_channels[0]
      block = Bottleneck
      num_blocks = self.stage1_num_blocks[0]
      self.layer1 = self._make_layer(
          block, 64, num_channels, num_blocks
      )
      stage1_out_channel = block.expansion * num_channels
  
      num_channels = self.stage2_num_channels
      block = GeneralTransformerBlock
      num_channels = [
          num_channels[i] * block.expansion
          for i in range(len(num_channels))
      ]
      self.transition1 = self._make_transition_layer(
          [stage1_out_channel], num_channels
      )
      self.stage2, pre_stage_channels = self._make_stage(
          block=block,
          num_modules=self.stage2_num_modules,
          num_branches=self.stage2_num_branches,
          num_blocks=self.stage2_num_blocks,
          num_channels=self.stage2_num_channels,
          num_heads=self.stage2_num_heads,
          num_window_sizes=self.stage2_num_window_sizes,
          num_mlp_ratios=self.stage2_num_mlp_ratios,
          num_inchannels=num_channels,
          drop_path=dpr[0:depth_s2],
      )
  
      num_channels = self.stage3_num_channels
      block = GeneralTransformerBlock
      num_channels = [
          num_channels[i] * block.expansion
          for i in range(len(num_channels))
      ]
      self.transition2 = self._make_transition_layer(
          pre_stage_channels, num_channels
      )
      self.stage3, pre_stage_channels = self._make_stage(
          block=block,
          num_modules=self.stage3_num_modules,
          num_branches=self.stage3_num_branches,
          num_blocks=self.stage3_num_blocks,
          num_channels=self.stage3_num_channels,
          num_heads=self.stage3_num_heads,
          num_window_sizes=self.stage3_num_window_sizes,
          num_mlp_ratios=self.stage3_num_mlp_ratios,
          num_inchannels=num_channels,
          drop_path=dpr[depth_s2 : depth_s2 + depth_s3],
      )
  
      num_channels = self.stage4_num_channels
      block = GeneralTransformerBlock
      num_channels = [
          num_channels[i] * block.expansion
          for i in range(len(num_channels))
      ]
      self.transition3 = self._make_transition_layer(
          pre_stage_channels, num_channels
      )
      self.stage4, pre_stage_channels = self._make_stage(
          block=block,
          num_modules=self.stage4_num_modules,
          num_branches=self.stage4_num_branches,
          num_blocks=self.stage4_num_blocks,
          num_channels=self.stage4_num_channels,
          num_heads=self.stage4_num_heads,
          num_window_sizes=self.stage4_num_window_sizes,
          num_mlp_ratios=self.stage4_num_mlp_ratios,
          num_inchannels=num_channels,
          multi_scale_output=True,
          drop_path=dpr[depth_s2 + depth_s3 :],
      )
  
      self.init_weight()
  
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddleseg.cvlibs import manager, param_init
  from paddleseg.models import layers
  from paddleseg.utils import utils, logger
  from paddleseg.models.backbones.transformer_utils import *
label_desc: Use image node_id 1 to create a new HighResolutionTransformer object from inherited base classes: nn with example: obj = HighResolutionTransformer(drop_path_rate, stage1_num_blocks, stage1_num_channels, stage2_num_modules, stage2_num_branches, stage2_num_blocks, stage2_num_channels, stage2_num_heads, stage2_num_mlp_ratios, stage2_num_window_sizes, stage3_num_modules, stage3_num_branches, stage3_num_blocks, stage3_num_channels, stage3_num_heads, stage3_num_mlp_ratios, stage3_num_window_sizes, stage4_num_modules, stage4_num_branches, stage4_num_blocks, stage4_num_channels, stage4_num_heads, stage4_num_mlp_ratios, stage4_num_window_sizes, in_channels, pretrained)