class_docstr: Swin Transformer Block.
  Args:
      dim (int): Number of input channels.
      input_resolution (tuple[int]): Input resulotion.
      num_heads (int): Number of attention heads.
      window_size (int, optional): Window size. Default: 7
      shift_size (int, optional): Shift size for SW-MSA.
      mlp_ratio (float, optional): Ratio of mlp hidden dim to embedding dim.
      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.
      drop (float, optional): Dropout rate. Default: 0.0
      attn_drop (float, optional): Attention dropout rate. Default: 0.0
      drop_path (float, optional): Stochastic depth rate. Default: 0.0
      act_layer (nn.Layer, optional): Activation layer. Default: nn.GELU
      norm_layer (nn.Layer, optional): Normalization layer.  Default: nn.LayerNorm
class_docstr_tok: ["Swin","Transformer","Block",".","Args",":","dim","(","int",")",":","Number","of","input","channels",".","input_resolution","(","tuple","[","int","]",")",":","Input","resulotion",".","num_heads","(","int",")",":","Number","of","attention","heads",".","window_size","(","int",",","optional",")",":","Window","size",".","Default",":","7","shift_size","(","int",",","optional",")",":","Shift","size","for","SW-MSA",".","mlp_ratio","(","float",",","optional",")",":","Ratio","of","mlp","hidden","dim","to","embedding","dim",".","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",".","drop","(","float",",","optional",")",":","Dropout","rate",".","Default",":","0.0","attn_drop","(","float",",","optional",")",":","Attention","dropout","rate",".","Default",":","0.0","drop_path","(","float",",","optional",")",":","Stochastic","depth","rate",".","Default",":","0.0","act_layer","(","nn.Layer",",","optional",")",":","Activation","layer",".","Default",":","nn.GELU","norm_layer","(","nn.Layer",",","optional",")",":","Normalization","layer",".","Default",":","nn.LayerNorm"]
code: def forward(self, x):
      H, W = self.input_resolution
      B, L, C = x.shape
      assert L == H * W, "input feature has wrong size"
  
      shortcut = x
      x = self.norm1(x)
      x = x.reshape([B, H, W, C])
  
      # cyclic shift
      if self.shift_size > 0:
          shifted_x = paddle.roll(
              x,
              shifts=(-self.shift_size, -self.shift_size),
              axis=(1, 2),
          )
      else:
          shifted_x = x
  
      # partition windows
      x_windows = window_partition(
          shifted_x, self.window_size
      )  # nW*B, window_size, window_size, C
      x_windows = x_windows.reshape(
          [-1, self.window_size * self.window_size, C]
      )  # nW*B, window_size*window_size, C
  
      # W-MSA/SW-MSA
      attn_windows = self.attn(
          x_windows, mask=self.attn_mask
      )  # nW*B, window_size*window_size, C
  
      # merge windows
      attn_windows = attn_windows.reshape(
          [-1, self.window_size, self.window_size, C]
      )
      shifted_x = window_reverse(
          attn_windows, self.window_size, H, W, C
      )  # B H' W' C
  
      # reverse cyclic shift
      if self.shift_size > 0:
          x = paddle.roll(
              shifted_x,
              shifts=(self.shift_size, self.shift_size),
              axis=(1, 2),
          )
      else:
          x = shifted_x
      x = x.reshape([B, H * W, C])
  
      # FFN
      x = shortcut + self.drop_path(x)
      x = x + self.drop_path(self.mlp(self.norm2(x)))
  
      return x
  
imports: import numpy
  import paddle
  import paddle.nn
  from medicalseg.cvlibs import manager, param_init
  from medicalseg.utils import load_pretrained_model
  from medicalseg.models.backbones.transformer_utils import DropPath, to_2tuple
label_desc: Use image node_id 2 for calling the SwinTransformerBlock obj's underlying member method code with example usage: obj.forward(x) and returns: x