code: def __init__(
      self,
      dim,
      patches,
      depth,
      num_heads,
      mlp_ratio,
      qkv_bias=False,
      proj_drop=0.0,
      attn_drop=0.0,
      drop_path=0.0,
      act_layer=nn.GELU,
      norm_layer=nn.LayerNorm,
  ):
      super().__init__()
  
      num_branches = len(dim)
      self.num_branches = num_branches
      # different branch could have different embedding size, the first one is the base
      self.blocks = nn.ModuleList()
      for d in range(num_branches):
          tmp = []
          for i in range(depth[d]):
              tmp.append(
                  Block(
                      dim=dim[d],
                      num_heads=num_heads[d],
                      mlp_ratio=mlp_ratio[d],
                      qkv_bias=qkv_bias,
                      proj_drop=proj_drop,
                      attn_drop=attn_drop,
                      drop_path=drop_path[i],
                      norm_layer=norm_layer,
                  )
              )
          if len(tmp) != 0:
              self.blocks.append(nn.Sequential(*tmp))
  
      if len(self.blocks) == 0:
          self.blocks = None
  
      self.projs = nn.ModuleList()
      for d in range(num_branches):
          if dim[d] == dim[(d + 1) % num_branches] and False:
              tmp = [nn.Identity()]
          else:
              tmp = [
                  norm_layer(dim[d]),
                  act_layer(),
                  nn.Linear(dim[d], dim[(d + 1) % num_branches]),
              ]
          self.projs.append(nn.Sequential(*tmp))
  
      self.fusion = nn.ModuleList()
      for d in range(num_branches):
          d_ = (d + 1) % num_branches
          nh = num_heads[d_]
          if depth[-1] == 0:  # backward capability:
              self.fusion.append(
                  CrossAttentionBlock(
                      dim=dim[d_],
                      num_heads=nh,
                      mlp_ratio=mlp_ratio[d],
                      qkv_bias=qkv_bias,
                      proj_drop=proj_drop,
                      attn_drop=attn_drop,
                      drop_path=drop_path[-1],
                      norm_layer=norm_layer,
                  )
              )
          else:
              tmp = []
              for _ in range(depth[-1]):
                  tmp.append(
                      CrossAttentionBlock(
                          dim=dim[d_],
                          num_heads=nh,
                          mlp_ratio=mlp_ratio[d],
                          qkv_bias=qkv_bias,
                          proj_drop=proj_drop,
                          attn_drop=attn_drop,
                          drop_path=drop_path[-1],
                          norm_layer=norm_layer,
                      )
                  )
              self.fusion.append(nn.Sequential(*tmp))
  
      self.revert_projs = nn.ModuleList()
      for d in range(num_branches):
          if dim[(d + 1) % num_branches] == dim[d] and False:
              tmp = [nn.Identity()]
          else:
              tmp = [
                  norm_layer(dim[(d + 1) % num_branches]),
                  act_layer(),
                  nn.Linear(dim[(d + 1) % num_branches], dim[d]),
              ]
          self.revert_projs.append(nn.Sequential(*tmp))
  
imports: from functools import partial
  from typing import List
  from typing import Tuple
  import torch
  import torch.hub
  import torch.nn
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import DropPath, to_2tuple, trunc_normal_, _assert
  from ._builder import build_model_with_cfg
  from ._features_fx import register_notrace_function
  from ._registry import register_model, generate_default_cfgs
  from .vision_transformer import Block
label_desc: Use image node_id 1 to create a new MultiScaleBlock object from inherited base classes: nn with example: obj = MultiScaleBlock(dim, patches, depth, num_heads, mlp_ratio, qkv_bias, proj_drop, attn_drop, drop_path, act_layer, norm_layer)