class_docstr: See :func:`shifted_window_attention`.
class_docstr_tok: ["See",":","func",":","`","shifted_window_attention","`","."]
docstr: Args:
      x (Tensor): Tensor with layout of [B, H, W, C]
  Returns:
      Tensor with same layout as input, i.e. [B, H, W, C]
docstr_tok: ["Args",":","x","(","Tensor",")",":","Tensor","with","layout","of","[","B",",","H",",","W",",","C","]","Returns",":","Tensor","with","same","layout","as","input",",","i.e",".","[","B",",","H",",","W",",","C","]"]
code: def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
      """
      Args:
          x (Tensor): Tensor with layout of [B, H, W, C]
      Returns:
          Tensor with same layout as input, i.e. [B, H, W, C]
      """
  
      N = self.window_size[0] * self.window_size[1]
      relative_position_bias = self.relative_position_bias_table[self.relative_position_index]  # type: ignore[index]
      relative_position_bias = relative_position_bias.view(N, N, -1)
      relative_position_bias = (
          relative_position_bias.permute(2, 0, 1)
          .contiguous()
          .unsqueeze(0)
      )
  
      return shifted_window_attention(
          x,
          self.qkv.weight,
          self.proj.weight,
          relative_position_bias,
          self.window_size,
          self.num_heads,
          shift_size=self.shift_size,
          attention_dropout=self.attention_dropout,
          dropout=self.dropout,
          qkv_bias=self.qkv.bias,
          proj_bias=self.proj.bias,
      )
  
imports: from typing import List, Optional
  import torch
  from torch import Tensor, nn
  from torch.nn import functional
  from cvnets.layers import Dropout, LinearLayer, StochasticDepth, get_normalization_layer
  from cvnets.layers.activation import build_activation_layer
  from cvnets.modules import BaseModule
label_desc: Use image node_id 3 for calling the ShiftedWindowAttention obj's underlying member method code with example usage: obj.forward(x) and returns: shifted_window_attention