class_docstr: See :func:`shifted_window_attention_v2`.
class_docstr_tok: ["See",":","func",":","`","shifted_window_attention_v2","`","."]
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__(
          dim,
          window_size,
          shift_size,
          num_heads,
          qkv_bias=qkv_bias,
          proj_bias=proj_bias,
          attention_dropout=attention_dropout,
          dropout=dropout,
      )
  
      self.logit_scale = nn.Parameter(
          torch.log(10 * torch.ones((num_heads, 1, 1)))
      )
      # mlp to generate continuous relative position bias
      self.cpb_mlp = nn.Sequential(
          nn.Linear(2, 512, bias=True),
          nn.ReLU(inplace=True),
          nn.Linear(512, num_heads, bias=False),
      )
      if qkv_bias:
          length = self.qkv.bias.numel() // 3
          self.qkv.bias[length : 2 * length].data.zero_()
  
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 ShiftedWindowAttentionV2 object from inherited base classes: ShiftedWindowAttention with example: obj = ShiftedWindowAttentionV2(dim, window_size, shift_size, num_heads, qkv_bias, proj_bias, attention_dropout, dropout)