class_docstr: A basic TinyViT layer for one stage.
  
  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.
      drop (float, optional): Dropout rate. Default: 0.0
      drop_path (float | tuple[float], optional): Stochastic depth rate. Default: 0.0
      downsample (nn.Module | None, optional): Downsample layer at the end of the layer. Default: None
      local_conv_size: the kernel size of the depthwise convolution between attention and MLP. Default: 3
      activation: the activation function. Default: nn.GELU
      out_dim: the output dimension of the layer. Default: dim
class_docstr_tok: ["A","basic","TinyViT","layer","for","one","stage",".","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",".","drop","(","float",",","optional",")",":","Dropout","rate",".","Default",":","0.0","drop_path","(","float","|","tuple","[","float","]",",","optional",")",":","Stochastic","depth","rate",".","Default",":","0.0","downsample","(","nn.Module","|","None",",","optional",")",":","Downsample","layer","at","the","end","of","the","layer",".","Default",":","None","local_conv_size",":","the","kernel","size","of","the","depthwise","convolution","between","attention","and","MLP",".","Default",":","3","activation",":","the","activation","function",".","Default",":","nn.GELU","out_dim",":","the","output","dimension","of","the","layer",".","Default",":","dim"]
code: def __init__(
      self,
      dim,
      input_resolution,
      depth,
      num_heads,
      window_size,
      mlp_ratio=4.0,
      drop=0.0,
      drop_path=0.0,
      downsample=None,
      local_conv_size=3,
      activation=nn.GELU,
      out_dim=None,
  ):
      super().__init__()
      self.dim = dim
      self.input_resolution = input_resolution
      self.depth = depth
  
      # build blocks
      self.blocks = nn.LayerList(
          [
              TinyViTBlock(
                  dim=dim,
                  input_resolution=input_resolution,
                  num_heads=num_heads,
                  window_size=window_size,
                  mlp_ratio=mlp_ratio,
                  drop=drop,
                  drop_path=drop_path[i]
                  if isinstance(drop_path, list)
                  else drop_path,
                  local_conv_size=local_conv_size,
                  activation=activation,
              )
              for i in range(depth)
          ]
      )
  
      # patch merging layer
      if downsample is not None:
          self.downsample = downsample(
              input_resolution,
              dim=dim,
              out_dim=out_dim,
              activation=activation,
          )
      else:
          self.downsample = None
  
imports: import itertools
  import paddle
  from paddle import nn
  from paddle.nn import functional
  from .common import LayerNorm2d
label_desc: Use image node_id 1 to create a new BasicLayer object from inherited base classes: nn with example: obj = BasicLayer(dim, input_resolution, depth, num_heads, window_size, mlp_ratio, drop, drop_path, downsample, local_conv_size, activation, out_dim)