code: def __init__(
      self,
      *,
      num_classes,
      s1_emb_dim=64,
      s1_patch_size=4,
      s1_local_patch_size=7,
      s1_global_k=7,
      s1_depth=1,
      s2_emb_dim=128,
      s2_patch_size=2,
      s2_local_patch_size=7,
      s2_global_k=7,
      s2_depth=1,
      s3_emb_dim=256,
      s3_patch_size=2,
      s3_local_patch_size=7,
      s3_global_k=7,
      s3_depth=5,
      s4_emb_dim=512,
      s4_patch_size=2,
      s4_local_patch_size=7,
      s4_global_k=7,
      s4_depth=4,
      peg_kernel_size=3,
      dropout=0.0,
  ):
      super().__init__()
      kwargs = dict(locals())
  
      dim = 3
      layers = []
  
      for prefix in ("s1", "s2", "s3", "s4"):
          config, kwargs = group_by_key_prefix_and_remove_prefix(
              f"{prefix}_", kwargs
          )
          is_last = prefix == "s4"
  
          dim_next = config["emb_dim"]
  
          layers.append(
              nn.Sequential(
                  PatchEmbedding(
                      dim=dim,
                      dim_out=dim_next,
                      patch_size=config["patch_size"],
                  ),
                  Transformer(
                      dim=dim_next,
                      depth=1,
                      local_patch_size=config["local_patch_size"],
                      global_k=config["global_k"],
                      dropout=dropout,
                      has_local=not is_last,
                  ),
                  PEG(dim=dim_next, kernel_size=peg_kernel_size),
                  Transformer(
                      dim=dim_next,
                      depth=config["depth"],
                      local_patch_size=config["local_patch_size"],
                      global_k=config["global_k"],
                      dropout=dropout,
                      has_local=not is_last,
                  ),
              )
          )
  
          dim = dim_next
  
      self.layers = nn.Sequential(
          *layers,
          nn.AdaptiveAvgPool2d(1),
          Rearrange("... () () -> ..."),
          nn.Linear(dim, num_classes),
      )
  
imports: import torch
  from torch import nn, einsum
  import torch.nn.functional
  from einops import rearrange, repeat
  from einops.layers.torch import Rearrange
label_desc: Use image node_id 1 to create a new TwinsSVT object from inherited base classes: nn with example: obj = TwinsSVT()