class_docstr: Serial block class.
  Note: In this implementation, each serial block only contains a conv-attention and a FFN (MLP) module. 
class_docstr_tok: ["Serial","block","class",".","Note",":","In","this","implementation",",","each","serial","block","only","contains","a","conv-attention","and","a","FFN","(","MLP",")","module","."]
code: def __init__(
      self,
      dim,
      num_heads,
      mlp_ratio=4.0,
      qkv_bias=False,
      proj_drop=0.0,
      attn_drop=0.0,
      drop_path=0.0,
      act_layer=nn.GELU,
      norm_layer=nn.LayerNorm,
      shared_cpe=None,
      shared_crpe=None,
  ):
      super().__init__()
  
      # Conv-Attention.
      self.cpe = shared_cpe
  
      self.norm1 = norm_layer(dim)
      self.factoratt_crpe = FactorAttnConvRelPosEnc(
          dim,
          num_heads=num_heads,
          qkv_bias=qkv_bias,
          attn_drop=attn_drop,
          proj_drop=proj_drop,
          shared_crpe=shared_crpe,
      )
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
  
      # MLP.
      self.norm2 = norm_layer(dim)
      mlp_hidden_dim = int(dim * mlp_ratio)
      self.mlp = Mlp(
          in_features=dim,
          hidden_features=mlp_hidden_dim,
          act_layer=act_layer,
          drop=proj_drop,
      )
  
imports: from functools import partial
  from typing import Tuple, List, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import PatchEmbed, Mlp, DropPath, to_2tuple, trunc_normal_, _assert, LayerNorm
  from ._builder import build_model_with_cfg
  from ._registry import register_model, generate_default_cfgs
label_desc: Use image node_id 1 to create a new SerialBlock object from inherited base classes: nn with example: obj = SerialBlock(dim, num_heads, mlp_ratio, qkv_bias, proj_drop, attn_drop, drop_path, act_layer, norm_layer, shared_cpe, shared_crpe)