class_docstr: Swin Transformer Block.
  
  Args:
      dim (int): Number of input channels.
      input_resolution (tuple[int]): Input resolution.
      num_heads (int): Number of attention heads.
      window_size (int): Window size.
      shift_size (int): Shift size for SW-MSA.
      mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
      qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
      qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set.
      drop (float, optional): Dropout rate. Default: 0.0
      attn_drop (float, optional): Attention dropout rate. Default: 0.0
      drop_path (float, optional): Stochastic depth rate. Default: 0.0
      act_layer (nn.Module, optional): Activation layer. Default: nn.GELU
      norm_layer (nn.Module, optional): Normalization layer.  Default: nn.LayerNorm
code: def forward(self, x):
      B, initial_H, initial_W, C = x.shape
  
      shortcut = x
      x = self.norm1(x)
  
      # If window size is larger than input resolution, we don't partition windows
      window_size, shift_size = get_window_size(
          (initial_H, initial_W),
          (self.window_size, self.window_size),
          (self.shift_size, self.shift_size),
      )
      window_size = min(window_size)
      shift_size = min(shift_size)
  
      # Pad feature map to multiple of window size
      pad_l = pad_t = 0
      pad_b = (window_size - initial_H % window_size) % window_size
      pad_r = (window_size - initial_W % window_size) % window_size
      x = F.pad(x, (0, 0, pad_l, pad_r, pad_t, pad_b))
      B, H, W, C = x.shape
  
      # cyclic shift
      if shift_size > 0:
          shifted_x = torch.roll(
              x, shifts=(-shift_size, -shift_size), dims=(1, 2)
          )
      else:
          shifted_x = x
  
      # partition windows
      x_windows = window_partition(
          shifted_x, window_size
      )  # nW*B, window_size, window_size, C
      x_windows = x_windows.view(
          -1, window_size * window_size, C
      )  # nW*B, window_size*window_size, C
  
      # W-MSA/SW-MSA
      attn_mask = compute_mask(H, W, window_size, shift_size, x.device)
      attn_windows = self.attn(
          x_windows, mask=attn_mask
      )  # nW*B, window_size*window_size, C
  
      # merge windows
      attn_windows = attn_windows.view(-1, window_size, window_size, C)
      shifted_x = window_reverse(
          attn_windows, window_size, H, W
      )  # B H' W' C
  
      # reverse cyclic shift
      if shift_size > 0:
          x = torch.roll(
              shifted_x, shifts=(shift_size, shift_size), dims=(1, 2)
          )
      else:
          x = shifted_x
  
      # Remove the added padding used for attention (needed for the shortcut)
      if pad_r > 0 or pad_b > 0:
          x = x[:, :initial_H, :initial_W, :].contiguous()
  
      # FFN
      x = shortcut + self.drop_path(x)
      x = x + self.drop_path(self.mlp(self.norm2(x)))
  
      return x
  
imports: import math
  from functools import lru_cache
  from typing import List, Optional
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from vissl.config import AttrDict
  from vissl.models.model_helpers import DropPath, rearrange, to_2tuple, trunc_normal_
  from vissl.models.trunks import register_model_trunk
label_desc: Use image node_id 2 for calling the SwinTransformerBlock obj's underlying member method code with example usage: obj.forward(x) and returns: x