class_docstr: Residual Swin Transformer Block (RSTB).
  
  Args:
      dim (int): Number of input channels.
      input_resolution (tuple[int]): Input resolution.
      depth (int): Number of blocks.
      num_heads (int): Number of attention heads.
      window_size (int): Local window size.
      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 | tuple[float], optional): Stochastic depth rate. Default: 0.0
      norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
      downsample (nn.Module | None, optional): Downsample layer at the end of the layer. Default: None
      use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False.
      img_size: Input image size.
      patch_size: Patch size.
      resi_connection: The convolutional block before residual connection.
class_docstr_tok: ["Residual","Swin","Transformer","Block","(","RSTB",")",".","Args",":","dim","(","int",")",":","Number","of","input","channels",".","input_resolution","(","tuple","[","int","]",")",":","Input","resolution",".","depth","(","int",")",":","Number","of","blocks",".","num_heads","(","int",")",":","Number","of","attention","heads",".","window_size","(","int",")",":","Local","window","size",".","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","|","tuple","[","float","]",",","optional",")",":","Stochastic","depth","rate",".","Default",":","0.0","norm_layer","(","nn.Module",",","optional",")",":","Normalization","layer",".","Default",":","nn.LayerNorm","downsample","(","nn.Module","|","None",",","optional",")",":","Downsample","layer","at","the","end","of","the","layer",".","Default",":","None","use_checkpoint","(","bool",")",":","Whether","to","use","checkpointing","to","save","memory",".","Default",":","False",".","img_size",":","Input","image","size",".","patch_size",":","Patch","size",".","resi_connection",":","The","convolutional","block","before","residual","connection","."]
code: def __init__(
      self,
      dim,
      input_resolution,
      depth,
      num_heads,
      window_size,
      mlp_ratio=4.0,
      qkv_bias=True,
      qk_scale=None,
      drop=0.0,
      attn_drop=0.0,
      drop_path=0.0,
      norm_layer=nn.LayerNorm,
      downsample=None,
      use_checkpoint=False,
      img_size=224,
      patch_size=4,
      resi_connection="1conv",
  ):
      super(RSTB, self).__init__()
  
      self.dim = dim
      self.input_resolution = input_resolution
  
      self.residual_group = BasicLayer(
          dim=dim,
          input_resolution=input_resolution,
          depth=depth,
          num_heads=num_heads,
          window_size=window_size,
          mlp_ratio=mlp_ratio,
          qkv_bias=qkv_bias,
          qk_scale=qk_scale,
          drop=drop,
          attn_drop=attn_drop,
          drop_path=drop_path,
          norm_layer=norm_layer,
          downsample=downsample,
          use_checkpoint=use_checkpoint,
      )
  
      if resi_connection == "1conv":
          self.conv = nn.Conv2d(dim, dim, 3, 1, 1)
      elif resi_connection == "3conv":
          # to save parameters and memory
          self.conv = nn.Sequential(
              nn.Conv2d(dim, dim // 4, 3, 1, 1),
              nn.LeakyReLU(negative_slope=0.2, inplace=True),
              nn.Conv2d(dim // 4, dim // 4, 1, 1, 0),
              nn.LeakyReLU(negative_slope=0.2, inplace=True),
              nn.Conv2d(dim // 4, dim, 3, 1, 1),
          )
  
      self.patch_embed = PatchEmbed(
          img_size=img_size,
          patch_size=patch_size,
          in_chans=0,
          embed_dim=dim,
          norm_layer=None,
      )
  
      self.patch_unembed = PatchUnEmbed(
          img_size=img_size,
          patch_size=patch_size,
          in_chans=0,
          embed_dim=dim,
          norm_layer=None,
      )
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from timm.models.layers import DropPath, to_2tuple, trunc_normal_
label_desc: Use image node_id 1 to create a new RSTB object from inherited base classes: nn with example: obj = RSTB(dim, input_resolution, depth, num_heads, window_size, mlp_ratio, qkv_bias, qk_scale, drop, attn_drop, drop_path, norm_layer, downsample, use_checkpoint, img_size, patch_size, resi_connection)