class_docstr: A basic Swin Transformer layer for one stage.
  
  Args:
      dim (int): Number of feature channels.
      depth (int): Depths of this stage.
      num_heads (int): Number of attention head.
      window_size (int): Local window size. Default: 7.
      mlp_ratio (float): 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 qk scale of head_dim ** -0.5 if set.
      drop (float, optional): Dropout rate. Default: 0.0
      attn_drop (float, optional): Attention dropout rate. Default: 0.0
      drop_path (float | tuple[float], optional): Stochastic depth rate. Default: 0.0
      norm_layer (nn.Layer, optional): Normalization layer. Default: nn.LayerNorm
      downsample (nn.Layer | None, optional): Downsample layer at the end of the layer. Default: None
class_docstr_tok: ["A","basic","Swin","Transformer","layer","for","one","stage",".","Args",":","dim","(","int",")",":","Number","of","feature","channels",".","depth","(","int",")",":","Depths","of","this","stage",".","num_heads","(","int",")",":","Number","of","attention","head",".","window_size","(","int",")",":","Local","window","size",".","Default",":","7.","mlp_ratio","(","float",")",":","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","qk","scale","of","head_dim","*","*","-0.5","if","set",".","drop","(","float",",","optional",")",":","Dropout","rate",".","Default",":","0.0","attn_drop","(","float",",","optional",")",":","Attention","dropout","rate",".","Default",":","0.0","drop_path","(","float","|","tuple","[","float","]",",","optional",")",":","Stochastic","depth","rate",".","Default",":","0.0","norm_layer","(","nn.Layer",",","optional",")",":","Normalization","layer",".","Default",":","nn.LayerNorm","downsample","(","nn.Layer","|","None",",","optional",")",":","Downsample","layer","at","the","end","of","the","layer",".","Default",":","None"]
docstr: Args:
      x: Input feature, tensor size (B, H*W, C).
      H, W: Spatial resolution of the input feature.
docstr_tok: ["Args",":","x",":","Input","feature",",","tensor","size","(","B",",","H","*","W",",","C",")",".","H",",","W",":","Spatial","resolution","of","the","input","feature","."]
code: def forward(self, x, H, W):
      """
      Args:
          x: Input feature, tensor size (B, H*W, C).
          H, W: Spatial resolution of the input feature.
      """
      # calculate attention mask for SW-MSA
      Hp = int(np.ceil(H / self.window_size)) * self.window_size
      Wp = int(np.ceil(W / self.window_size)) * self.window_size
      img_mask = paddle.zeros((1, Hp, Wp, 1))  # 1 Hp Wp 1
      h_slices = (
          slice(0, -self.window_size),
          slice(-self.window_size, -self.shift_size),
          slice(-self.shift_size, None),
      )
      w_slices = (
          slice(0, -self.window_size),
          slice(-self.window_size, -self.shift_size),
          slice(-self.shift_size, None),
      )
      cnt = 0
      for h in h_slices:
          for w in w_slices:
              img_mask[:, h, w, :] = cnt
              cnt += 1
  
      mask_windows = window_partition(
          img_mask, self.window_size
      )  # nW, window_size, window_size, 1
      mask_windows = mask_windows.reshape(
          [-1, self.window_size * self.window_size]
      )
      attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)
  
      huns = -100.0 * paddle.ones_like(attn_mask)
      attn_mask = huns * (attn_mask != 0).astype("float32")
  
      for blk in self.blocks:
          blk.H, blk.W = H, W
          x = blk(x, attn_mask)
      if self.downsample is not None:
          x_down = self.downsample(x, H, W)
          Wh, Ww = (H + 1) // 2, (W + 1) // 2
          return x, H, W, x_down, Wh, Ww
      else:
          return x, H, W, x, H, W
  
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  import numpy
  from paddleseg.cvlibs import manager
  from paddleseg.utils import utils
  from paddleseg.models.backbones.transformer_utils import *
label_desc: Use image node_id 2 for calling the BasicLayer obj's underlying member method code with example usage: obj.forward(x, H, W) and returns: x,  H,  W,  x_down,  Wh,  Ww, x,  H,  W,  x,  H,  W