docstr: SwinTransformer Block
          
docstr_tok: ["SwinTransformer","Block"]
code: def __init__(
      self,
      input_dim,
      output_dim,
      head_dim,
      window_size,
      drop_path,
      type="W",
      input_resolution=None,
  ):
      """SwinTransformer Block"""
      super(Block, self).__init__()
      self.input_dim = input_dim
      self.output_dim = output_dim
      assert type in ["W", "SW"]
      self.type = type
      if input_resolution <= window_size:
          self.type = "W"
  
      self.ln1 = nn.LayerNorm(input_dim)
      self.msa = WMSA(
          input_dim, input_dim, head_dim, window_size, self.type
      )
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
      self.ln2 = nn.LayerNorm(input_dim)
      self.mlp = nn.Sequential(
          nn.Linear(input_dim, 4 * input_dim),
          nn.GELU(),
          nn.Linear(4 * input_dim, output_dim),
      )
  
imports: import numpy
  import torch
  import torch.nn
  from einops import rearrange
  from einops.layers.torch import Rearrange
  from timm.models.layers import trunc_normal_, DropPath
label_desc: Use image node_id 1 to create a new Block object from inherited base classes: nn with example: obj = Block(input_dim, output_dim, head_dim, window_size, drop_path, type, input_resolution)