class_docstr: See :func:`shifted_window_attention`.
class_docstr_tok: ["See",":","func",":","`","shifted_window_attention","`","."]
code: def __init__(
      self,
      dim: int,
      window_size: List[int],
      shift_size: List[int],
      num_heads: int,
      qkv_bias: bool = True,
      proj_bias: bool = True,
      attention_dropout: float = 0.0,
      dropout: float = 0.0,
  ):
      super().__init__()
      if len(window_size) != 2 or len(shift_size) != 2:
          raise ValueError(
              "window_size and shift_size must be of length 2"
          )
      self.window_size = window_size
      self.shift_size = shift_size
      self.num_heads = num_heads
      self.attention_dropout = attention_dropout
      self.dropout = dropout
  
      self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
      self.proj = nn.Linear(dim, dim, bias=proj_bias)
  
      self.define_relative_position_bias_table()
      self.define_relative_position_index()
  
imports: import math
  from functools import partial
  from typing import Any, Callable, List, Optional
  import torch
  import torch.nn.functional
  from torch import nn, Tensor
  from ..ops.misc import MLP, Permute
  from ..ops.stochastic_depth import StochasticDepth
  from ..transforms._presets import ImageClassification, InterpolationMode
  from ..utils import _log_api_usage_once
  from ._api import register_model, Weights, WeightsEnum
  from ._meta import _IMAGENET_CATEGORIES
  from ._utils import _ovewrite_named_param, handle_legacy_interface
label_desc: Use image node_id 1 to create a new ShiftedWindowAttention object from inherited base classes: nn with example: obj = ShiftedWindowAttention(dim, window_size, shift_size, num_heads, qkv_bias, proj_bias, attention_dropout, dropout)