class_docstr: MetaFormer
  Args:
      layers (tuple[int]): number of blocks for the 4 stages
      embed_dims (tuple[int]): embedding dimension
      mlp_ratios (tuple[float]): mlp ratios
      token_mixers (tuple[nn.module]): token mixers of different stages
      norm_layer (nn.module): normalization layer
      act_layer (nn.module): activation layer
      num_classes (int): number of classes
      in_patch_size (int): patch embedding size
      in_stride (int): stride of patch embedding
      in_pad (int): padding
      down_patch_size (int): down sample path size
      add_pos_embs (bool): down sample path size
      drop_rate (float): drop rate
      drop_path_rate (float): drop path rate
      use_layer_scale (bool): use layer scale
      layer_scale_init_value (float): layer scale init value
class_docstr_tok: ["MetaFormer","Args",":","layers","(","tuple","[","int","]",")",":","number","of","blocks","for","the","4","stages","embed_dims","(","tuple","[","int","]",")",":","embedding","dimension","mlp_ratios","(","tuple","[","float","]",")",":","mlp","ratios","token_mixers","(","tuple","[","nn.module","]",")",":","token","mixers","of","different","stages","norm_layer","(","nn.module",")",":","normalization","layer","act_layer","(","nn.module",")",":","activation","layer","num_classes","(","int",")",":","number","of","classes","in_patch_size","(","int",")",":","patch","embedding","size","in_stride","(","int",")",":","stride","of","patch","embedding","in_pad","(","int",")",":","padding","down_patch_size","(","int",")",":","down","sample","path","size","add_pos_embs","(","bool",")",":","down","sample","path","size","drop_rate","(","float",")",":","drop","rate","drop_path_rate","(","float",")",":","drop","path","rate","use_layer_scale","(","bool",")",":","use","layer","scale","layer_scale_init_value","(","float",")",":","layer","scale","init","value"]
code: def __init__(
      self,
      layers,
      embed_dims=None,
      token_mixers=None,
      mlp_ratios=None,
      norm_layer=LayerNormChannel,
      act_layer=nn.GELU,
      num_classes=1000,
      in_patch_size=7,
      in_stride=4,
      in_pad=2,
      downsamples=None,
      down_patch_size=3,
      down_stride=2,
      down_pad=1,
      add_pos_embs=None,
      drop_rate=0.0,
      drop_path_rate=0.0,
      use_layer_scale=True,
      layer_scale_init_value=1e-5,
  ):
      super().__init__()
      self.num_classes = num_classes
  
      self.patch_embed = PatchEmbed(
          patch_size=in_patch_size,
          stride=in_stride,
          padding=in_pad,
          in_chans=3,
          embed_dim=embed_dims[0],
      )
      if add_pos_embs is None:
          add_pos_embs = [None] * len(layers)
      if token_mixers is None:
          token_mixers = [nn.Identity] * len(layers)
      # set the main block in network
      network = []
      for i in range(len(layers)):
          if add_pos_embs[i] is not None:
              network.append(add_pos_embs[i](embed_dims[i]))
          stage = basic_blocks(
              embed_dims[i],
              i,
              layers,
              token_mixer=token_mixers[i],
              mlp_ratio=mlp_ratios[i],
              act_layer=act_layer,
              norm_layer=norm_layer,
              drop_rate=drop_rate,
              drop_path_rate=drop_path_rate,
              use_layer_scale=use_layer_scale,
              layer_scale_init_value=layer_scale_init_value,
          )
          network.append(stage)
          if i >= len(layers) - 1:
              break
          if downsamples[i] or embed_dims[i] != embed_dims[i + 1]:
              # downsampling between two stages
              network.append(
                  PatchEmbed(
                      patch_size=down_patch_size,
                      stride=down_stride,
                      padding=down_pad,
                      in_chans=embed_dims[i],
                      embed_dim=embed_dims[i + 1],
                  )
              )
  
      self.network = nn.ModuleList(network)
      self.norm = norm_layer(embed_dims[-1])
      self.head = (
          nn.Linear(embed_dims[-1], num_classes)
          if num_classes > 0
          else nn.Identity()
      )
  
      self.apply(self.cls_init_weights)
  
imports: from torch import nn
  import torch
  from functools import partial
  from towhee.models.utils.weight_init import trunc_normal_
  from towhee.models.poolformer.groupnorm import GroupNorm
  from towhee.models.poolformer.layernormchannel import LayerNormChannel
  from towhee.models.poolformer.pooling import Pooling
  from towhee.models.metaformer.basicblocks import basic_blocks
  from towhee.models.poolformer.patchembed import PatchEmbed
  from towhee.models.metaformer.addpositionembed import AddPositionEmb
  from towhee.models.metaformer.attention import Attention
  from towhee.models.metaformer.spatialfc import SpatialFc
label_desc: Use image node_id 1 to create a new MetaFormer object from inherited base classes: nn with example: obj = MetaFormer(layers, embed_dims, token_mixers, mlp_ratios, norm_layer, act_layer, num_classes, in_patch_size, in_stride, in_pad, downsamples, down_patch_size, down_stride, down_pad, add_pos_embs, drop_rate, drop_path_rate, use_layer_scale, layer_scale_init_value)