class_docstr: Based on timm and DeiT code bases
  https://github.com/rwightman/pytorch-image-models/tree/master/timm
  https://github.com/facebookresearch/deit/
class_docstr_tok: ["Based","on","timm","and","DeiT","code","bases","https",":","\/\/github.com\/rwightman\/pytorch-image-models\/tree\/master\/timm","https",":","\/\/github.com\/facebookresearch\/deit\/"]
code: def __init__(self, model_config: AttrDict, model_name: str):
      super().__init__()
  
      assert model_config.INPUT_TYPE in [
          "rgb",
          "bgr",
      ], "Input type not supported"
      trunk_config = model_config.TRUNK.XCIT
  
      logging.info("Building model: XCiT from yaml config")
      self.model_config = model_config
      self.trunk_config = trunk_config
      self.img_size = trunk_config.IMAGE_SIZE
      self.patch_size = trunk_config.PATCH_SIZE
      self.embed_dim = trunk_config.HIDDEN_DIM
      self.depth = trunk_config.NUM_LAYERS
      self.num_heads = trunk_config.NUM_HEADS
      self.mlp_ratio = trunk_config.MLP_RATIO
      self.qkv_bias = trunk_config.QKV_BIAS
      self.qk_scale = trunk_config.QK_SCALE
      self.drop_rate = trunk_config.DROPOUT_RATE
      self.attn_drop_rate = trunk_config.ATTENTION_DROPOUT_RATE
      self.drop_path_rate = trunk_config.DROP_PATH_RATE
      self.eta = trunk_config.ETA
      self.tokens_norm = trunk_config.TOKENS_NORM
  
      # num_features for consistency with other models
      self.num_features = self.embed_dim
  
      self.patch_embed = ConvPatchEmbed(
          img_size=self.img_size,
          embed_dim=self.embed_dim,
          patch_size=self.patch_size,
      )
      self.num_patches = self.patch_embed.num_patches
  
      norm_layer = partial(nn.LayerNorm, eps=1e-6)
  
      self.cls_token = nn.Parameter(torch.zeros(1, 1, self.embed_dim))
      self.pos_drop = nn.Dropout(p=self.drop_rate)
  
      self.blocks = self._create_xca_blocks(norm_layer)
  
      self.cls_attn_blocks = self._create_cls_attn_blocks(norm_layer)
      self.norm = norm_layer(self.embed_dim)
  
      self.pos_embeder = PositionalEncodingFourier(dim=self.embed_dim)
      self.use_pos = True
  
      # Initialize weights
      trunc_normal_(self.cls_token, std=0.02)
      self.patch_embed.apply(self._init_weights)
      self.pos_embeder.apply(self._init_weights)
      self.norm.apply(self._init_weights)
  
imports: import logging
  import math
  from functools import partial
  from typing import List, Optional
  import torch
  import torch.nn
  from fairscale.nn import checkpoint_wrapper
  from vissl.config import AttrDict
  from vissl.models.model_helpers import DropPath, to_2tuple, trunc_normal_
  from vissl.models.trunks import register_model_trunk
  from vissl.models.trunks.vision_transformer import Mlp
  from vissl.utils.fsdp_utils import fsdp_wrapper
  from vissl.utils.misc import set_torch_seed
label_desc: Use image node_id 1 to create a new XCiT object from inherited base classes: nn with example: obj = XCiT(model_config, model_name)