class_docstr: Vision Transformer with support for patch or hybrid CNN input stage
      
class_docstr_tok: ["Vision","Transformer","with","support","for","patch","or","hybrid","CNN","input","stage"]
code: def __init__(
      self,
      img_size=224,
      img_scale=(1.0, 1.0),
      patch_size=(8, 16),
      in_chans=3,
      num_classes=1000,
      embed_dim=(192, 384),
      depth=((1, 3, 1), (1, 3, 1), (1, 3, 1)),
      num_heads=(6, 12),
      mlp_ratio=(2.0, 2.0, 4.0),
      multi_conv=False,
      crop_scale=False,
      qkv_bias=True,
      drop_rate=0.0,
      pos_drop_rate=0.0,
      proj_drop_rate=0.0,
      attn_drop_rate=0.0,
      drop_path_rate=0.0,
      norm_layer=partial(nn.LayerNorm, eps=1e-6),
      global_pool="token",
  ):
      super().__init__()
      assert global_pool in ("token", "avg")
  
      self.num_classes = num_classes
      self.global_pool = global_pool
      self.img_size = to_2tuple(img_size)
      img_scale = to_2tuple(img_scale)
      self.img_size_scaled = [
          tuple([int(sj * si) for sj in self.img_size])
          for si in img_scale
      ]
      self.crop_scale = (
          crop_scale  # crop instead of interpolate for scale
      )
      num_patches = _compute_num_patches(
          self.img_size_scaled, patch_size
      )
      self.num_branches = len(patch_size)
      self.embed_dim = embed_dim
      self.num_features = sum(embed_dim)
      self.patch_embed = nn.ModuleList()
  
      # hard-coded for torch jit script
      for i in range(self.num_branches):
          setattr(
              self,
              f"pos_embed_{i}",
              nn.Parameter(
                  torch.zeros(1, 1 + num_patches[i], embed_dim[i])
              ),
          )
          setattr(
              self,
              f"cls_token_{i}",
              nn.Parameter(torch.zeros(1, 1, embed_dim[i])),
          )
  
      for im_s, p, d in zip(
          self.img_size_scaled, patch_size, embed_dim
      ):
          self.patch_embed.append(
              PatchEmbed(
                  img_size=im_s,
                  patch_size=p,
                  in_chans=in_chans,
                  embed_dim=d,
                  multi_conv=multi_conv,
              )
          )
  
      self.pos_drop = nn.Dropout(p=pos_drop_rate)
  
      total_depth = sum([sum(x[-2:]) for x in depth])
      dpr = [
          x.item()
          for x in torch.linspace(0, drop_path_rate, total_depth)
      ]  # stochastic depth decay rule
      dpr_ptr = 0
      self.blocks = nn.ModuleList()
      for idx, block_cfg in enumerate(depth):
          curr_depth = max(block_cfg[:-1]) + block_cfg[-1]
          dpr_ = dpr[dpr_ptr : dpr_ptr + curr_depth]
          blk = MultiScaleBlock(
              embed_dim,
              num_patches,
              block_cfg,
              num_heads=num_heads,
              mlp_ratio=mlp_ratio,
              qkv_bias=qkv_bias,
              proj_drop=proj_drop_rate,
              attn_drop=attn_drop_rate,
              drop_path=dpr_,
              norm_layer=norm_layer,
          )
          dpr_ptr += curr_depth
          self.blocks.append(blk)
  
      self.norm = nn.ModuleList(
          [norm_layer(embed_dim[i]) for i in range(self.num_branches)]
      )
      self.head_drop = nn.Dropout(drop_rate)
      self.head = nn.ModuleList(
          [
              nn.Linear(embed_dim[i], num_classes)
              if num_classes > 0
              else nn.Identity()
              for i in range(self.num_branches)
          ]
      )
  
      for i in range(self.num_branches):
          trunc_normal_(getattr(self, f"pos_embed_{i}"), std=0.02)
          trunc_normal_(getattr(self, f"cls_token_{i}"), std=0.02)
  
      self.apply(self._init_weights)
  
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 CrossVit object from inherited base classes: nn with example: obj = CrossVit(img_size, img_scale, patch_size, in_chans, num_classes, embed_dim, depth, num_heads, mlp_ratio, multi_conv, crop_scale, qkv_bias, drop_rate, pos_drop_rate, proj_drop_rate, attn_drop_rate, drop_path_rate, norm_layer, global_pool)