class_docstr: The UHRNet implementation based on PaddlePaddle.
  
  The original article refers to
  Jian Wang, et, al. "U-HRNet: Delving into Improving Semantic Representation of High Resolution Network for Dense Prediction"
  (https://arxiv.org/pdf/2210.07140.pdf).
  
  Args:
      in_channels (int, optional): The channels of input image. Default: 3.
      pretrained (str): The path of pretrained model.
      stage1_num_modules (int): Number of modules for stage1. Default 1.
      stage1_num_blocks (list): Number of blocks per module for stage1. Default [4].
      stage1_num_channels (list): Number of channels per branch for stage1. Default [64].
      stage2_num_modules (int): Number of modules for stage2. Default 1.
      stage2_num_blocks (list): Number of blocks per module for stage2. Default [4, 4]
      stage2_num_channels (list): Number of channels per branch for stage2. Default [18, 36].
      stage3_num_modules (int): Number of modules for stage3. Default 5.
      stage3_num_blocks (list): Number of blocks per module for stage3. Default [4, 4]
      stage3_num_channels (list): Number of channels per branch for stage3. Default [36, 72].
      stage4_num_modules (int): Number of modules for stage4. Default 2.
      stage4_num_blocks (list): Number of blocks per module for stage4. Default [4, 4]
      stage4_num_channels (list): Number of channels per branch for stage4. Default [72. 144].
      stage5_num_modules (int): Number of modules for stage5. Default 2.
      stage5_num_blocks (list): Number of blocks per module for stage5. Default [4, 4]
      stage5_num_channels (list): Number of channels per branch for stage5. Default [144, 288].
      stage6_num_modules (int): Number of modules for stage6. Default 1.
      stage6_num_blocks (list): Number of blocks per module for stage6. Default [4, 4]
      stage6_num_channels (list): Number of channels per branch for stage6. Default [72. 144].
      stage7_num_modules (int): Number of modules for stage7. Default 1.
      stage7_num_blocks (list): Number of blocks per module for stage7. Default [4, 4]
      stage7_num_channels (list): Number of channels per branch for stage7. Default [36, 72].
      stage8_num_modules (int): Number of modules for stage8. Default 1.
      stage8_num_blocks (list): Number of blocks per module for stage8. Default [4, 4]
      stage8_num_channels (list): Number of channels per branch for stage8. Default [18, 36].
      stage9_num_modules (int): Number of modules for stage9. Default 1.
      stage9_num_blocks (list): Number of blocks per module for stage9. Default [4]
      stage9_num_channels (list): Number of channels per branch for stage9. Default [18].
      has_se (bool): Whether to use Squeeze-and-Excitation module. Default False.
      align_corners (bool, optional): An argument of F.interpolate. It should be set to False when the feature size is even,
          e.g. 1024x512, otherwise it is True, e.g. 769x769. Default: False.
class_docstr_tok: ["The","UHRNet","implementation","based","on","PaddlePaddle",".","The","original","article","refers","to","Jian","Wang",",","et",",","al",".","``","U-HRNet",":","Delving","into","Improving","Semantic","Representation","of","High","Resolution","Network","for","Dense","Prediction","''","(","https",":","\/\/arxiv.org\/pdf\/2210.07140.pdf",")",".","Args",":","in_channels","(","int",",","optional",")",":","The","channels","of","input","image",".","Default",":","3.","pretrained","(","str",")",":","The","path","of","pretrained","model",".","stage1_num_modules","(","int",")",":","Number","of","modules","for","stage1",".","Default","1.","stage1_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage1",".","Default","[","4","]",".","stage1_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage1",".","Default","[","64","]",".","stage2_num_modules","(","int",")",":","Number","of","modules","for","stage2",".","Default","1.","stage2_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage2",".","Default","[","4",",","4","]","stage2_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage2",".","Default","[","18",",","36","]",".","stage3_num_modules","(","int",")",":","Number","of","modules","for","stage3",".","Default","5.","stage3_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage3",".","Default","[","4",",","4","]","stage3_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage3",".","Default","[","36",",","72","]",".","stage4_num_modules","(","int",")",":","Number","of","modules","for","stage4",".","Default","2.","stage4_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage4",".","Default","[","4",",","4","]","stage4_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage4",".","Default","[","72",".","144","]",".","stage5_num_modules","(","int",")",":","Number","of","modules","for","stage5",".","Default","2.","stage5_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage5",".","Default","[","4",",","4","]","stage5_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage5",".","Default","[","144",",","288","]",".","stage6_num_modules","(","int",")",":","Number","of","modules","for","stage6",".","Default","1.","stage6_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage6",".","Default","[","4",",","4","]","stage6_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage6",".","Default","[","72",".","144","]",".","stage7_num_modules","(","int",")",":","Number","of","modules","for","stage7",".","Default","1.","stage7_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage7",".","Default","[","4",",","4","]","stage7_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage7",".","Default","[","36",",","72","]",".","stage8_num_modules","(","int",")",":","Number","of","modules","for","stage8",".","Default","1.","stage8_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage8",".","Default","[","4",",","4","]","stage8_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage8",".","Default","[","18",",","36","]",".","stage9_num_modules","(","int",")",":","Number","of","modules","for","stage9",".","Default","1.","stage9_num_blocks","(","list",")",":","Number","of","blocks","per","module","for","stage9",".","Default","[","4","]","stage9_num_channels","(","list",")",":","Number","of","channels","per","branch","for","stage9",".","Default","[","18","]",".","has_se","(","bool",")",":","Whether","to","use","Squeeze-and-Excitation","module",".","Default","False",".","align_corners","(","bool",",","optional",")",":","An","argument","of","F.interpolate",".","It","should","be","set","to","False","when","the","feature","size","is","even",",","e.g",".","1024x512",",","otherwise","it","is","True",",","e.g",".","769x769",".","Default",":","False","."]
code: def __init__(
      self,
      in_channels=3,
      pretrained=None,
      stage1_num_modules=1,
      stage1_num_blocks=(4,),
      stage1_num_channels=(64,),
      stage2_num_modules=1,
      stage2_num_blocks=(4, 4),
      stage2_num_channels=(18, 36),
      stage3_num_modules=5,
      stage3_num_blocks=(4, 4),
      stage3_num_channels=(36, 72),
      stage4_num_modules=2,
      stage4_num_blocks=(4, 4),
      stage4_num_channels=(72, 144),
      stage5_num_modules=2,
      stage5_num_blocks=(4, 4),
      stage5_num_channels=(144, 288),
      stage6_num_modules=1,
      stage6_num_blocks=(4, 4),
      stage6_num_channels=(72, 144),
      stage7_num_modules=1,
      stage7_num_blocks=(4, 4),
      stage7_num_channels=(36, 72),
      stage8_num_modules=1,
      stage8_num_blocks=(4, 4),
      stage8_num_channels=(18, 36),
      stage9_num_modules=1,
      stage9_num_blocks=(4,),
      stage9_num_channels=(18,),
      has_se=False,
      align_corners=False,
  ):
      super(UHRNet, self).__init__()
      self.pretrained = pretrained
      self.has_se = has_se
      self.align_corners = align_corners
      self.feat_channels = [
          sum(
              [
                  stage5_num_channels[-1],
                  stage6_num_channels[-1],
                  stage7_num_channels[-1],
                  stage8_num_channels[-1],
                  stage9_num_channels[-1],
              ]
          )
          // 2
      ]
  
      cur_stride = 1
      # stem net
      self.conv_layer1_1 = layers.ConvBNReLU(
          in_channels=3,
          out_channels=64,
          kernel_size=3,
          stride=2,
          padding="same",
          bias_attr=False,
      )
      cur_stride *= 2
  
      self.conv_layer1_2 = layers.ConvBNReLU(
          in_channels=64,
          out_channels=64,
          kernel_size=3,
          stride=2,
          padding="same",
          bias_attr=False,
      )
      cur_stride *= 2
  
      self.la1 = Layer1(
          num_channels=64,
          num_blocks=stage1_num_blocks[0],
          num_filters=stage1_num_channels[0],
          has_se=has_se,
          name="layer2",
      )
  
      self.tr1 = TransitionLayer(
          stride_pre=cur_stride,
          in_channel=stage1_num_channels[0] * 4,
          stride_cur=[
              cur_stride * (2**i)
              for i in range(len(stage2_num_channels))
          ],
          out_channels=stage2_num_channels,
          align_corners=self.align_corners,
          name="tr1",
      )
      self.st2 = Stage(
          num_channels=stage2_num_channels,
          num_modules=stage2_num_modules,
          num_blocks=stage2_num_blocks,
          num_filters=stage2_num_channels,
          has_se=self.has_se,
          name="st2",
          align_corners=align_corners,
      )
      cur_stride *= 2
  
      self.tr2 = TransitionLayer(
          stride_pre=cur_stride,
          in_channel=stage2_num_channels[-1],
          stride_cur=[
              cur_stride * (2**i)
              for i in range(len(stage3_num_channels))
          ],
          out_channels=stage3_num_channels,
          align_corners=self.align_corners,
          name="tr2",
      )
      self.st3 = Stage(
          num_channels=stage3_num_channels,
          num_modules=stage3_num_modules,
          num_blocks=stage3_num_blocks,
          num_filters=stage3_num_channels,
          has_se=self.has_se,
          name="st3",
          align_corners=align_corners,
      )
      cur_stride *= 2
  
      self.tr3 = TransitionLayer(
          stride_pre=cur_stride,
          in_channel=stage3_num_channels[-1],
          stride_cur=[
              cur_stride * (2**i)
              for i in range(len(stage4_num_channels))
          ],
          out_channels=stage4_num_channels,
          align_corners=self.align_corners,
          name="tr3",
      )
      self.st4 = Stage(
          num_channels=stage4_num_channels,
          num_modules=stage4_num_modules,
          num_blocks=stage4_num_blocks,
          num_filters=stage4_num_channels,
          has_se=self.has_se,
          name="st4",
          align_corners=align_corners,
      )
      cur_stride *= 2
  
      self.tr4 = TransitionLayer(
          stride_pre=cur_stride,
          in_channel=stage4_num_channels[-1],
          stride_cur=[
              cur_stride * (2**i)
              for i in range(len(stage5_num_channels))
          ],
          out_channels=stage5_num_channels,
          align_corners=self.align_corners,
          name="tr4",
      )
      self.st5 = Stage(
          num_channels=stage5_num_channels,
          num_modules=stage5_num_modules,
          num_blocks=stage5_num_blocks,
          num_filters=stage5_num_channels,
          has_se=self.has_se,
          name="st5",
          align_corners=align_corners,
      )
  
      self.tr5 = TransitionLayer(
          stride_pre=cur_stride,
          in_channel=stage5_num_channels[0],
          stride_cur=[
              cur_stride // (2 ** (len(stage6_num_channels) - i - 1))
              for i in range(len(stage6_num_channels))
          ],
          out_channels=stage6_num_channels,
          align_corners=self.align_corners,
          name="tr5",
      )
      self.st6 = Stage(
          num_channels=stage6_num_channels,
          num_modules=stage6_num_modules,
          num_blocks=stage6_num_blocks,
          num_filters=stage6_num_channels,
          has_se=self.has_se,
          name="st6",
          align_corners=align_corners,
      )
      cur_stride = cur_stride // 2
  
      self.tr6 = TransitionLayer(
          stride_pre=cur_stride,
          in_channel=stage6_num_channels[0],
          stride_cur=[
              cur_stride // (2 ** (len(stage7_num_channels) - i - 1))
              for i in range(len(stage7_num_channels))
          ],
          out_channels=stage7_num_channels,
          align_corners=self.align_corners,
          name="tr6",
      )
      self.st7 = Stage(
          num_channels=stage7_num_channels,
          num_modules=stage7_num_modules,
          num_blocks=stage7_num_blocks,
          num_filters=stage7_num_channels,
          has_se=self.has_se,
          name="st7",
          align_corners=align_corners,
      )
      cur_stride = cur_stride // 2
  
      self.tr7 = TransitionLayer(
          stride_pre=cur_stride,
          in_channel=stage7_num_channels[0],
          stride_cur=[
              cur_stride // (2 ** (len(stage8_num_channels) - i - 1))
              for i in range(len(stage8_num_channels))
          ],
          out_channels=stage8_num_channels,
          align_corners=self.align_corners,
          name="tr7",
      )
      self.st8 = Stage(
          num_channels=stage8_num_channels,
          num_modules=stage8_num_modules,
          num_blocks=stage8_num_blocks,
          num_filters=stage8_num_channels,
          has_se=self.has_se,
          name="st8",
          align_corners=align_corners,
      )
      cur_stride = cur_stride // 2
  
      self.tr8 = TransitionLayer(
          stride_pre=cur_stride,
          in_channel=stage8_num_channels[0],
          stride_cur=[
              cur_stride // (2 ** (len(stage9_num_channels) - i - 1))
              for i in range(len(stage9_num_channels))
          ],
          out_channels=stage9_num_channels,
          align_corners=self.align_corners,
          name="tr8",
      )
      self.st9 = Stage(
          num_channels=stage9_num_channels,
          num_modules=stage9_num_modules,
          num_blocks=stage9_num_blocks,
          num_filters=stage9_num_channels,
          has_se=self.has_se,
          name="st9",
          align_corners=align_corners,
      )
  
      self.last_layer = nn.Sequential(
          layers.ConvBNReLU(
              in_channels=self.feat_channels[0],
              out_channels=self.feat_channels[0],
              kernel_size=1,
              padding="same",
              stride=1,
          ),
          nn.Conv2D(
              in_channels=self.feat_channels[0],
              out_channels=19,
              kernel_size=1,
              stride=1,
              padding=0,
          ),
      )
      self.init_weight()
  
imports: import math
  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
label_desc: Use image node_id 1 to create a new UHRNet object from inherited base classes: nn with example: obj = UHRNet(in_channels, pretrained, stage1_num_modules, stage1_num_blocks, stage1_num_channels, stage2_num_modules, stage2_num_blocks, stage2_num_channels, stage3_num_modules, stage3_num_blocks, stage3_num_channels, stage4_num_modules, stage4_num_blocks, stage4_num_channels, stage5_num_modules, stage5_num_blocks, stage5_num_channels, stage6_num_modules, stage6_num_blocks, stage6_num_channels, stage7_num_modules, stage7_num_blocks, stage7_num_channels, stage8_num_modules, stage8_num_blocks, stage8_num_channels, stage9_num_modules, stage9_num_blocks, stage9_num_channels, has_se, align_corners)