class_docstr: Swin Transformer Block.
  
  Args:
      dim (int): Number of input channels.
      num_heads (int): Number of attention heads.
      window_size (int): Window size.
      shift_size (int): Shift size for SW-MSA.
      mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
      qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
      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
class_docstr_tok: ["Swin","Transformer","Block",".","Args",":","dim","(","int",")",":","Number","of","input","channels",".","num_heads","(","int",")",":","Number","of","attention","heads",".","window_size","(","int",")",":","Window","size",".","shift_size","(","int",")",":","Shift","size","for","SW-MSA",".","mlp_ratio","(","float",")",":","Ratio","of","mlp","hidden","dim","to","embedding","dim",".","qkv_bias","(","bool",",","optional",")",":","If","True",",","add","a","learnable","bias","to","query",",","key",",","value",".","Default",":","True","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"]
code: def __init__(
      self,
      dim,
      num_heads,
      window_size=7,
      shift_size=0,
      mlp_ratio=4.0,
      qkv_bias=True,
      drop=0.0,
      attn_drop=0.0,
      drop_path=0.0,
      name=None,
  ):
      super().__init__(name=name)
      self.dim = dim
      self.num_heads = num_heads
      self.window_size = window_size
      self.shift_size = shift_size
      self.mlp_ratio = mlp_ratio
      assert (
          0 <= self.shift_size < self.window_size
      ), "shift_size must in 0-window_size"
  
      self.norm1 = layers.LayerNormalization(epsilon=1e-6, name="norm1")
      self.attn = WindowAttention(
          dim,
          window_size=(window_size, window_size),
          num_heads=num_heads,
          qkv_bias=qkv_bias,
          attn_drop_ratio=attn_drop,
          proj_drop_ratio=drop,
          name="attn",
      )
      self.drop_path = (
          layers.Dropout(rate=drop_path, noise_shape=(None, 1, 1))
          if drop_path > 0.0
          else layers.Activation("linear")
      )
      self.norm2 = layers.LayerNormalization(epsilon=1e-6, name="norm2")
      self.mlp = MLP(dim, drop=drop, name="mlp")
  
imports: import tensorflow
  from tensorflow.keras import Model, layers, initializers
  import numpy
label_desc: Use image node_id 1 to create a new SwinTransformerBlock object from inherited base classes: layers with example: obj = SwinTransformerBlock(dim, num_heads, window_size, shift_size, mlp_ratio, qkv_bias, drop, attn_drop, drop_path, name)