class_docstr: Shifted Window Multihead Self-Attention Module.
  
  Args:
      embed_dims (int): Number of input channels.
      num_heads (int): Number of attention heads.
      window_size (int): The height and width of the window.
      shift_size (int, optional): The shift step of each window towards
          right-bottom. If zero, act as regular window-msa. Defaults to 0.
      qkv_bias (bool, optional): If True, add a learnable bias to q, k, v.
          Default: True
      qk_scale (float | None, optional): Override default qk scale of
          head_dim ** -0.5 if set. Defaults: None.
      attn_drop_rate (float, optional): Dropout ratio of attention weight.
          Defaults: 0.
      proj_drop_rate (float, optional): Dropout ratio of output.
          Defaults: 0.
      dropout_layer (dict, optional): The dropout_layer used before output.
          Defaults: dict(type='DropPath', drop_prob=0.).
      init_cfg (dict, optional): The extra config for initialization.
          Default: None.
class_docstr_tok: ["Shifted","Window","Multihead","Self-Attention","Module",".","Args",":","embed_dims","(","int",")",":","Number","of","input","channels",".","num_heads","(","int",")",":","Number","of","attention","heads",".","window_size","(","int",")",":","The","height","and","width","of","the","window",".","shift_size","(","int",",","optional",")",":","The","shift","step","of","each","window","towards","right-bottom",".","If","zero",",","act","as","regular","window-msa",".","Defaults","to","0.","qkv_bias","(","bool",",","optional",")",":","If","True",",","add","a","learnable","bias","to","q",",","k",",","v.","Default",":","True","qk_scale","(","float","|","None",",","optional",")",":","Override","default","qk","scale","of","head_dim","*","*","-0.5","if","set",".","Defaults",":","None",".","attn_drop_rate","(","float",",","optional",")",":","Dropout","ratio","of","attention","weight",".","Defaults",":","0.","proj_drop_rate","(","float",",","optional",")",":","Dropout","ratio","of","output",".","Defaults",":","0.","dropout_layer","(","dict",",","optional",")",":","The","dropout_layer","used","before","output",".","Defaults",":","dict","(","type='DropPath","'",",","drop_prob=0.",")",".","init_cfg","(","dict",",","optional",")",":","The","extra","config","for","initialization",".","Default",":","None","."]
code: def __init__(
      self,
      embed_dims,
      num_heads,
      window_size,
      shift_size=0,
      qkv_bias=True,
      qk_scale=None,
      attn_drop_rate=0,
      proj_drop_rate=0,
      dropout_layer=dict(type="DropPath", drop_prob=0.0),
      init_cfg=None,
  ):
      super().__init__(init_cfg)
  
      self.window_size = window_size
      self.shift_size = shift_size
      assert 0 <= self.shift_size < self.window_size
  
      self.w_msa = WindowMSA(
          embed_dims=embed_dims,
          num_heads=num_heads,
          window_size=to_2tuple(window_size),
          qkv_bias=qkv_bias,
          qk_scale=qk_scale,
          attn_drop_rate=attn_drop_rate,
          proj_drop_rate=proj_drop_rate,
          init_cfg=None,
      )
  
      self.drop = build_dropout(dropout_layer)
  
imports: import warnings
  from collections import OrderedDict
  from copy import deepcopy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from mmcv.cnn import build_norm_layer
  from mmcv.cnn.bricks.transformer import FFN, build_dropout
  from mmengine.logging import MMLogger
  from mmengine.model import BaseModule, ModuleList
  from mmengine.model.weight_init import constant_init, trunc_normal_, trunc_normal_init
  from mmengine.runner.checkpoint import CheckpointLoader
  from mmengine.utils import to_2tuple
  from mmdet.registry import MODELS
  from ..layers import PatchEmbed, PatchMerging
label_desc: Use image node_id 1 to create a new ShiftWindowMSA object from inherited base classes: BaseModule with example: obj = ShiftWindowMSA(embed_dims, num_heads, window_size, shift_size, qkv_bias, qk_scale, attn_drop_rate, proj_drop_rate, dropout_layer, init_cfg)