class_docstr: Swin Transformer backbone.
      A PyTorch impl of : `Swin Transformer: Hierarchical Vision Transformer using Shifted Windows`  -
        https://arxiv.org/pdf/2103.14030
  
  Args:
      pretrain_img_size (int): Input image size for training the pretrained model,
          used in absolute postion embedding. Default 224.
      patch_size (int | tuple(int)): Patch size. Default: 4.
      in_chans (int): Number of input image channels. Default: 3.
      embed_dim (int): Number of linear projection output channels. Default: 96.
      depths (tuple[int]): Depths of each Swin Transformer stage.
      num_heads (tuple[int]): Number of attention head of each stage.
      window_size (int): Window size. Default: 7.
      mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. Default: 4.
      qkv_bias (bool): If True, add a learnable bias to query, key, value. Default: True
      qk_scale (float): Override default qk scale of head_dim ** -0.5 if set.
      drop_rate (float): Dropout rate.
      attn_drop_rate (float): Attention dropout rate. Default: 0.
      drop_path_rate (float): Stochastic depth rate. Default: 0.2.
      norm_layer (nn.Module): Normalization layer. Default: nn.LayerNorm.
      ape (bool): If True, add absolute position embedding to the patch embedding. Default: False.
      patch_norm (bool): If True, add normalization after patch embedding. Default: True.
      layers (Sequence[int]): Output from which stages.
      frozen_stages (int): Stages to be frozen (stop grad and set eval mode).
          -1 means not freezing any parameters.
      use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False.
class_docstr_tok: ["Swin","Transformer","backbone",".","A","PyTorch","impl","of",":","`","Swin","Transformer",":","Hierarchical","Vision","Transformer","using","Shifted","Windows","`","-","https",":","\/\/arxiv.org\/pdf\/2103.14030","Args",":","pretrain_img_size","(","int",")",":","Input","image","size","for","training","the","pretrained","model",",","used","in","absolute","postion","embedding",".","Default","224.","patch_size","(","int","|","tuple","(","int",")",")",":","Patch","size",".","Default",":","4.","in_chans","(","int",")",":","Number","of","input","image","channels",".","Default",":","3.","embed_dim","(","int",")",":","Number","of","linear","projection","output","channels",".","Default",":","96.","depths","(","tuple","[","int","]",")",":","Depths","of","each","Swin","Transformer","stage",".","num_heads","(","tuple","[","int","]",")",":","Number","of","attention","head","of","each","stage",".","window_size","(","int",")",":","Window","size",".","Default",":","7.","mlp_ratio","(","float",")",":","Ratio","of","mlp","hidden","dim","to","embedding","dim",".","Default",":","4.","qkv_bias","(","bool",")",":","If","True",",","add","a","learnable","bias","to","query",",","key",",","value",".","Default",":","True","qk_scale","(","float",")",":","Override","default","qk","scale","of","head_dim","*","*","-0.5","if","set",".","drop_rate","(","float",")",":","Dropout","rate",".","attn_drop_rate","(","float",")",":","Attention","dropout","rate",".","Default",":","0.","drop_path_rate","(","float",")",":","Stochastic","depth","rate",".","Default",":","0.2.","norm_layer","(","nn.Module",")",":","Normalization","layer",".","Default",":","nn.LayerNorm",".","ape","(","bool",")",":","If","True",",","add","absolute","position","embedding","to","the","patch","embedding",".","Default",":","False",".","patch_norm","(","bool",")",":","If","True",",","add","normalization","after","patch","embedding",".","Default",":","True",".","layers","(","Sequence","[","int","]",")",":","Output","from","which","stages",".","frozen_stages","(","int",")",":","Stages","to","be","frozen","(","stop","grad","and","set","eval","mode",")",".","-1","means","not","freezing","any","parameters",".","use_checkpoint","(","bool",")",":","Whether","to","use","checkpointing","to","save","memory",".","Default",":","False","."]
docstr: Forward function.
code: def forward(self, x):
      """Forward function."""
      x = self.patch_embed(x)
  
      Wh, Ww = x.size(2), x.size(3)
      if self.ape:
          # interpolate the position embedding to the corresponding size
          absolute_pos_embed = F.interpolate(
              self.absolute_pos_embed, size=(Wh, Ww), mode="bicubic"
          )
          x = (
              (x + absolute_pos_embed).flatten(2).transpose(1, 2)
          )  # B Wh*Ww C
      else:
          x = x.flatten(2).transpose(1, 2)
      x = self.pos_drop(x)
  
      outs = []
      for i in range(self.num_layers):
          layer = self.layers[i]
          x_out, H, W, x, Wh, Ww = layer(x, Wh, Ww)
  
          if i in self.out_indices:
              norm_layer = getattr(self, f"norm{i}")
              x_out = norm_layer(x_out)
  
              out = (
                  x_out.view(-1, H, W, self.num_features[i])
                  .permute(0, 3, 1, 2)
                  .contiguous()
              )
              outs.append(out)
  
      return _take(outs, self._layers)
  
imports: from collections import OrderedDict
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from torch import Tensor
  from .common import EncoderModule, _take, make_n_channel_input
  from ..activations import get_activation_block, ACT_GELU
  from timm.models.layers import DropPath, to_2tuple, trunc_normal_
label_desc: Use image node_id 4 for calling the SwinTransformer obj's underlying member method code with example usage: obj.forward(x) and returns: _take