code: def __init__(
      self,
      model_cnf: list,
      num_classes: int = 1000,
      num_features: int = 1280,
      dropout_rate: float = 0.2,
      drop_connect_rate: float = 0.2,
  ):
      super(EfficientNetV2, self).__init__()
  
      for cnf in model_cnf:
          assert len(cnf) == 8
  
      norm_layer = partial(nn.BatchNorm2d, eps=1e-3, momentum=0.1)
  
      stem_filter_num = model_cnf[0][4]
  
      self.stem = ConvBNAct(
          3,
          stem_filter_num,
          kernel_size=3,
          stride=2,
          norm_layer=norm_layer,
      )  # 激活函数默认是SiLU
  
      total_blocks = sum([i[0] for i in model_cnf])
      block_id = 0
      blocks = []
      for cnf in model_cnf:
          repeats = cnf[0]
          op = FusedMBConv if cnf[-2] == 0 else MBConv
          for i in range(repeats):
              blocks.append(
                  op(
                      kernel_size=cnf[1],
                      input_c=cnf[4] if i == 0 else cnf[5],
                      out_c=cnf[5],
                      expand_ratio=cnf[3],
                      stride=cnf[2] if i == 0 else 1,
                      se_ratio=cnf[-1],
                      drop_rate=drop_connect_rate
                      * block_id
                      / total_blocks,
                      norm_layer=norm_layer,
                  )
              )
              block_id += 1
      self.blocks = nn.Sequential(*blocks)
  
      head_input_c = model_cnf[-1][-3]
      head = OrderedDict()
  
      head.update(
          {
              "project_conv": ConvBNAct(
                  head_input_c,
                  num_features,
                  kernel_size=1,
                  norm_layer=norm_layer,
              )
          }
      )  # 激活函数默认是SiLU
  
      head.update({"avgpool": nn.AdaptiveAvgPool2d(1)})
      head.update({"flatten": nn.Flatten()})
  
      if dropout_rate > 0:
          head.update(
              {"dropout": nn.Dropout(p=dropout_rate, inplace=True)}
          )
      head.update({"classifier": nn.Linear(num_features, num_classes)})
  
      self.head = nn.Sequential(head)
  
      # initial weights
      for m in self.modules():
          if isinstance(m, nn.Conv2d):
              nn.init.kaiming_normal_(m.weight, mode="fan_out")
              if m.bias is not None:
                  nn.init.zeros_(m.bias)
          elif isinstance(m, nn.BatchNorm2d):
              nn.init.ones_(m.weight)
              nn.init.zeros_(m.bias)
          elif isinstance(m, nn.Linear):
              nn.init.normal_(m.weight, 0, 0.01)
              nn.init.zeros_(m.bias)
  
imports: from collections import OrderedDict
  from functools import partial
  from typing import Callable, Optional
  import torch.nn
  import torch
  from torch import Tensor
label_desc: Use image node_id 1 to create a new EfficientNetV2 object from inherited base classes: nn with example: obj = EfficientNetV2(model_cnf, num_classes, num_features, dropout_rate, drop_connect_rate)