class_docstr: Swin Transformer 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: ShiftedWindowAttention
class_docstr_tok: ["Swin","Transformer","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",":","ShiftedWindowAttention"]
code: def __init__(
      self,
      dim: int,
      num_heads: int,
      window_size: List[int],
      shift_size: List[int],
      mlp_ratio: float = 4.0,
      dropout: float = 0.0,
      attention_dropout: float = 0.0,
      stochastic_depth_prob: float = 0.0,
      norm_layer: Callable[..., nn.Module] = nn.LayerNorm,
      attn_layer: Callable[..., nn.Module] = ShiftedWindowAttention,
  ):
      super().__init__()
      _log_api_usage_once(self)
  
      self.norm1 = norm_layer(dim)
      self.attn = attn_layer(
          dim,
          window_size,
          shift_size,
          num_heads,
          attention_dropout=attention_dropout,
          dropout=dropout,
      )
      self.stochastic_depth = StochasticDepth(
          stochastic_depth_prob, "row"
      )
      self.norm2 = norm_layer(dim)
      self.mlp = MLP(
          dim,
          [int(dim * mlp_ratio), dim],
          activation_layer=nn.GELU,
          inplace=None,
          dropout=dropout,
      )
  
      for m in self.mlp.modules():
          if isinstance(m, nn.Linear):
              nn.init.xavier_uniform_(m.weight)
              if m.bias is not None:
                  nn.init.normal_(m.bias, std=1e-6)
  
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 SwinTransformerBlock object from inherited base classes: nn with example: obj = SwinTransformerBlock(dim, num_heads, window_size, shift_size, mlp_ratio, dropout, attention_dropout, stochastic_depth_prob, norm_layer, attn_layer)