class_docstr: SwinUNet.
  Args:
      backbone: Backbone of SwinUnet
      image_size (int, optional): Image size of input. Default: 224
      path_size (int, optional): Patch size of Patch Embed. Default: 4
      in_chans (int, optional): The inchannel of input. Default: 3
      num_classes (int, optional): Number of class. Default: 1000
      embed_dim (int, optional): The embed dim. Default: 96
      depths (list, optional): Block number of every encoder layer. Default: [2, 2, 2, 2]
      depths_decoder (list, optional): Block number of every decoder layer. Default: [1, 2, 2, 2]
      num_heads (int, optional): Number of attention heads. Default: [3, 6, 12, 24]
      window_size (int, optional): Window size. Default: 7
      mlp_ratio (float, optional): Ratio of mlp hidden dim to embedding dim. Default: 4
      qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
      qk_scale (float | None, optional): Override default query and key scale of head_dim ** -0.5 if set. Default: None
      drop_rate (float, optional): Dropout rate. Default: 0.0
      attn_drop_rate (float, optional): Attention dropout rate. Default: 0.0
      drop_path_rate (float, optional): Stochastic depth rate. Default: 0.0
      norm_layer (nn.Layer, optional): Normalization layer.  Default: nn.LayerNorm
      patch_norm (bool, optional): If True, add normalization after patch embedding. Default: True
      pretrained(bool |str, optional): The path of pre-trained model. Default: None
      final_unsample (bool, optional): The final sample class. Default: True
class_docstr_tok: ["SwinUNet",".","Args",":","backbone",":","Backbone","of","SwinUnet","image_size","(","int",",","optional",")",":","Image","size","of","input",".","Default",":","224","path_size","(","int",",","optional",")",":","Patch","size","of","Patch","Embed",".","Default",":","4","in_chans","(","int",",","optional",")",":","The","inchannel","of","input",".","Default",":","3","num_classes","(","int",",","optional",")",":","Number","of","class",".","Default",":","1000","embed_dim","(","int",",","optional",")",":","The","embed","dim",".","Default",":","96","depths","(","list",",","optional",")",":","Block","number","of","every","encoder","layer",".","Default",":","[","2",",","2",",","2",",","2","]","depths_decoder","(","list",",","optional",")",":","Block","number","of","every","decoder","layer",".","Default",":","[","1",",","2",",","2",",","2","]","num_heads","(","int",",","optional",")",":","Number","of","attention","heads",".","Default",":","[","3",",","6",",","12",",","24","]","window_size","(","int",",","optional",")",":","Window","size",".","Default",":","7","mlp_ratio","(","float",",","optional",")",":","Ratio","of","mlp","hidden","dim","to","embedding","dim",".","Default",":","4","qkv_bias","(","bool",",","optional",")",":","If","True",",","add","a","learnable","bias","to","query",",","key",",","value",".","Default",":","True","qk_scale","(","float","|","None",",","optional",")",":","Override","default","query","and","key","scale","of","head_dim","*","*","-0.5","if","set",".","Default",":","None","drop_rate","(","float",",","optional",")",":","Dropout","rate",".","Default",":","0.0","attn_drop_rate","(","float",",","optional",")",":","Attention","dropout","rate",".","Default",":","0.0","drop_path_rate","(","float",",","optional",")",":","Stochastic","depth","rate",".","Default",":","0.0","norm_layer","(","nn.Layer",",","optional",")",":","Normalization","layer",".","Default",":","nn.LayerNorm","patch_norm","(","bool",",","optional",")",":","If","True",",","add","normalization","after","patch","embedding",".","Default",":","True","pretrained","(","bool","|str",",","optional",")",":","The","path","of","pre-trained","model",".","Default",":","None","final_unsample","(","bool",",","optional",")",":","The","final","sample","class",".","Default",":","True"]
code: def __init__(
      self,
      backbone,
      img_size=224,
      patch_size=4,
      in_chans=3,
      num_classes=1000,
      embed_dim=96,
      depths=[2, 2, 2, 2],
      depths_decoder=[1, 2, 2, 2],
      num_heads=[3, 6, 12, 24],
      window_size=7,
      mlp_ratio=4.0,
      qkv_bias=True,
      qk_scale=None,
      drop_rate=0.0,
      attn_drop_rate=0.0,
      drop_path_rate=0.1,
      norm_layer=nn.LayerNorm,
      patch_norm=True,
      pretrained=None,
      final_upsample=True,
      **kwargs,
  ):
      super().__init__()
  
      self.backbone = backbone
      self.num_classes = num_classes
      self.num_layers = len(depths)
      self.mlp_ratio = mlp_ratio
      self.embed_dim = embed_dim
      self.patch_norm = patch_norm
      self.num_features = int(embed_dim * 2 ** (self.num_layers - 1))
      self.final_upsample = final_upsample
  
      patches_resolution = [img_size // patch_size] * 2
      self.patches_resolution = patches_resolution
  
      self.pretrained = pretrained
  
      # stochastic depth
      dpr = np.linspace(
          0, drop_path_rate, sum(depths)
      ).tolist()  # stochastic depth decay rule
      self.layers_up = nn.LayerList()
      self.concat_back_dim = nn.LayerList()
  
      for i_layer in range(self.num_layers):
          concat_linear = (
              nn.Linear(
                  2
                  * int(
                      embed_dim * 2 ** (self.num_layers - 1 - i_layer)
                  ),
                  int(embed_dim * 2 ** (self.num_layers - 1 - i_layer)),
              )
              if i_layer > 0
              else nn.Identity()
          )
          if i_layer == 0:
              layer_up = PatchExpand(
                  input_resolution=(
                      patches_resolution[0]
                      // (2 ** (self.num_layers - 1 - i_layer)),
                      patches_resolution[1]
                      // (2 ** (self.num_layers - 1 - i_layer)),
                  ),
                  dim=int(
                      embed_dim * 2 ** (self.num_layers - 1 - i_layer)
                  ),
                  dim_scale=2,
                  norm_layer=norm_layer,
              )
          else:
              layer_up = BasicUpLayer(
                  dim=int(
                      embed_dim * 2 ** (self.num_layers - 1 - i_layer)
                  ),
                  input_resolution=(
                      patches_resolution[0]
                      // (2 ** (self.num_layers - 1 - i_layer)),
                      patches_resolution[1]
                      // (2 ** (self.num_layers - 1 - i_layer)),
                  ),
                  depth=depths[(self.num_layers - 1 - i_layer)],
                  num_heads=num_heads[(self.num_layers - 1 - i_layer)],
                  window_size=window_size,
                  mlp_ratio=self.mlp_ratio,
                  qkv_bias=qkv_bias,
                  qk_scale=qk_scale,
                  drop=drop_rate,
                  attn_drop=attn_drop_rate,
                  drop_path=dpr[
                      sum(
                          depths[: (self.num_layers - 1 - i_layer)]
                      ) : sum(
                          depths[: (self.num_layers - 1 - i_layer) + 1]
                      )
                  ],
                  norm_layer=norm_layer,
                  upsample=PatchExpand
                  if (i_layer < self.num_layers - 1)
                  else None,
              )
          self.layers_up.append(layer_up)
          self.concat_back_dim.append(concat_linear)
  
      self.norm = norm_layer(self.num_features)
      self.norm_up = norm_layer(self.embed_dim)
  
      if self.final_upsample:
          self.up = FinalPatchExpandX4(
              input_resolution=(
                  img_size // patch_size,
                  img_size // patch_size,
              ),
              dim_scale=4,
              dim=embed_dim,
          )
          self.output = nn.Conv2D(
              in_channels=embed_dim,
              out_channels=self.num_classes,
              kernel_size=1,
              bias_attr=False,
          )
  
      self.init_weight()
  
imports: import numpy
  import paddle
  import paddle.nn
  from medicalseg.cvlibs import manager, param_init
  from medicalseg.models.backbones.swin_transformer import SwinTransformerBlock, window_partition
  from medicalseg.utils import load_pretrained_model
label_desc: Use image node_id 1 to create a new SwinUNet object from inherited base classes: nn with example: obj = SwinUNet(backbone, img_size, patch_size, in_chans, num_classes, embed_dim, depths, depths_decoder, num_heads, window_size, mlp_ratio, qkv_bias, qk_scale, drop_rate, attn_drop_rate, drop_path_rate, norm_layer, patch_norm, pretrained, final_upsample)