class_docstr: Swin Transformer block based on: "Liu et al.,
  Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
  <https://arxiv.org/abs/2103.14030>"
  https://github.com/microsoft/Swin-Transformer
docstr: Args:
      dim: number of feature channels.
      num_heads: number of attention heads.
      window_size: local window size.
      shift_size: window shift size.
      mlp_ratio: ratio of mlp hidden dim to embedding dim.
      qkv_bias: add a learnable bias to query, key, value.
      drop: dropout rate.
      attn_drop: attention dropout rate.
      drop_path: stochastic depth rate.
      act_layer: activation layer.
      norm_layer: normalization layer.
      use_checkpoint: use gradient checkpointing for reduced memory usage.
docstr_tok: ["Args",":","dim",":","number","of","feature","channels",".","num_heads",":","number","of","attention","heads",".","window_size",":","local","window","size",".","shift_size",":","window","shift","size",".","mlp_ratio",":","ratio","of","mlp","hidden","dim","to","embedding","dim",".","qkv_bias",":","add","a","learnable","bias","to","query",",","key",",","value",".","drop",":","dropout","rate",".","attn_drop",":","attention","dropout","rate",".","drop_path",":","stochastic","depth","rate",".","act_layer",":","activation","layer",".","norm_layer",":","normalization","layer",".","use_checkpoint",":","use","gradient","checkpointing","for","reduced","memory","usage","."]
code: def __init__(
      self,
      dim: int,
      num_heads: int,
      window_size: Sequence[int],
      shift_size: Sequence[int],
      mlp_ratio: float = 4.0,
      qkv_bias: bool = True,
      drop: float = 0.0,
      attn_drop: float = 0.0,
      drop_path: float = 0.0,
      act_layer: str = "GELU",
      norm_layer: type[LayerNorm] = nn.LayerNorm,
      use_checkpoint: bool = False,
  ) -> None:
      """
      Args:
          dim: number of feature channels.
          num_heads: number of attention heads.
          window_size: local window size.
          shift_size: window shift size.
          mlp_ratio: ratio of mlp hidden dim to embedding dim.
          qkv_bias: add a learnable bias to query, key, value.
          drop: dropout rate.
          attn_drop: attention dropout rate.
          drop_path: stochastic depth rate.
          act_layer: activation layer.
          norm_layer: normalization layer.
          use_checkpoint: use gradient checkpointing for reduced memory usage.
      """
  
      super().__init__()
      self.dim = dim
      self.num_heads = num_heads
      self.window_size = window_size
      self.shift_size = shift_size
      self.mlp_ratio = mlp_ratio
      self.use_checkpoint = use_checkpoint
      self.norm1 = norm_layer(dim)
      self.attn = WindowAttention(
          dim,
          window_size=self.window_size,
          num_heads=num_heads,
          qkv_bias=qkv_bias,
          attn_drop=attn_drop,
          proj_drop=drop,
      )
  
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
      self.norm2 = norm_layer(dim)
      mlp_hidden_dim = int(dim * mlp_ratio)
      self.mlp = Mlp(
          hidden_size=dim,
          mlp_dim=mlp_hidden_dim,
          act=act_layer,
          dropout_rate=drop,
          dropout_mode="swin",
      )
  
imports: from __future__ import annotations
  import itertools
  from collections.abc import Sequence
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from torch.nn import LayerNorm
  from typing_extensions import Final
  from monai.networks.blocks import MLPBlock
  from monai.networks.blocks import PatchEmbed, UnetOutBlock, UnetrBasicBlock, UnetrUpBlock
  from monai.networks.layers import DropPath, trunc_normal_
  from monai.utils import ensure_tuple_rep, look_up_option, optional_import
  from monai.utils.deprecate_utils import deprecated_arg
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, qkv_bias, drop, attn_drop, drop_path, act_layer, norm_layer, use_checkpoint)