class_docstr: Window based multi-head self attention (W-MSA) module with relative position bias.
  It supports both of shifted and non-shifted window.
  
  Args:
      dim (int): Number of input channels.
      window_size (tuple[int]): The height and width of the window.
      num_heads (int): Number of attention heads.
      qkv_bias (bool, optional):  If True, add a learnable bias to query, key, value. Default: True
      attn_drop_ratio (float, optional): Dropout ratio of attention weight. Default: 0.0
      proj_drop_ratio (float, optional): Dropout ratio of output. Default: 0.0
class_docstr_tok: ["Window","based","multi-head","self","attention","(","W-MSA",")","module","with","relative","position","bias",".","It","supports","both","of","shifted","and","non-shifted","window",".","Args",":","dim","(","int",")",":","Number","of","input","channels",".","window_size","(","tuple","[","int","]",")",":","The","height","and","width","of","the","window",".","num_heads","(","int",")",":","Number","of","attention","heads",".","qkv_bias","(","bool",",","optional",")",":","If","True",",","add","a","learnable","bias","to","query",",","key",",","value",".","Default",":","True","attn_drop_ratio","(","float",",","optional",")",":","Dropout","ratio","of","attention","weight",".","Default",":","0.0","proj_drop_ratio","(","float",",","optional",")",":","Dropout","ratio","of","output",".","Default",":","0.0"]
code: def __init__(
      self,
      dim,
      window_size,
      num_heads=8,
      qkv_bias=False,
      attn_drop_ratio=0.0,
      proj_drop_ratio=0.0,
      name=None,
  ):
      super(WindowAttention, self).__init__(name=name)
      self.dim = dim
      self.window_size = window_size  # [Mh, Mw]
      self.num_heads = num_heads
      head_dim = dim // num_heads
      self.scale = head_dim**-0.5
  
      self.qkv = layers.Dense(
          dim * 3,
          use_bias=qkv_bias,
          name="qkv",
          kernel_initializer=self.k_ini,
          bias_initializer=self.b_ini,
      )
      self.attn_drop = layers.Dropout(attn_drop_ratio)
      self.proj = layers.Dense(
          dim,
          name="proj",
          kernel_initializer=self.k_ini,
          bias_initializer=self.b_ini,
      )
      self.proj_drop = layers.Dropout(proj_drop_ratio)
  
imports: import tensorflow
  from tensorflow.keras import Model, layers, initializers
  import numpy
label_desc: Use image node_id 1 to create a new WindowAttention object from inherited base classes: layers with example: obj = WindowAttention(dim, window_size, num_heads, qkv_bias, attn_drop_ratio, proj_drop_ratio, name)