class_docstr: Swin Transformer V2 Block.
  Args:
      dim (int): Number of input channels.
      num_heads (int): Number of attention heads.
      window_size (List[int]): Window size.
      shift_size (List[int]): Shift size for shifted window attention.
      mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. Default: 4.0.
      dropout (float): Dropout rate. Default: 0.0.
      attention_dropout (float): Attention dropout rate. Default: 0.0.
      stochastic_depth_prob: (float): Stochastic depth rate. Default: 0.0.
      norm_layer (nn.Module): Normalization layer.  Default: nn.LayerNorm.
      attn_layer (nn.Module): Attention layer. Default: ShiftedWindowAttentionV2.
class_docstr_tok: ["Swin","Transformer","V2","Block",".","Args",":","dim","(","int",")",":","Number","of","input","channels",".","num_heads","(","int",")",":","Number","of","attention","heads",".","window_size","(","List","[","int","]",")",":","Window","size",".","shift_size","(","List","[","int","]",")",":","Shift","size","for","shifted","window","attention",".","mlp_ratio","(","float",")",":","Ratio","of","mlp","hidden","dim","to","embedding","dim",".","Default",":","4.0.","dropout","(","float",")",":","Dropout","rate",".","Default",":","0.0.","attention_dropout","(","float",")",":","Attention","dropout","rate",".","Default",":","0.0.","stochastic_depth_prob",":","(","float",")",":","Stochastic","depth","rate",".","Default",":","0.0.","norm_layer","(","nn.Module",")",":","Normalization","layer",".","Default",":","nn.LayerNorm",".","attn_layer","(","nn.Module",")",":","Attention","layer",".","Default",":","ShiftedWindowAttentionV2","."]
code: def forward(self, x: Tensor):
      # Here is the difference, we apply norm after the attention in V2.
      # In V1 we applied norm before the attention.
      x = x + self.stochastic_depth(self.norm1(self.attn(x)))
      x = x + self.stochastic_depth(self.norm2(self.mlp(x)))
      return x
  
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 2 for calling the SwinTransformerBlockV2 obj's underlying member method code with example usage: obj.forward(x) and returns: x