class_docstr: Vision transformer as per https://arxiv.org/abs/2010.11929.
class_docstr_tok: ["Vision","transformer","as","per","https",":","\/\/arxiv.org\/abs\/2010.11929","."]
code: def __init__(self, params=None):
      super(ViT, self).__init__()
      p = ViT.get_params() if not params else params
      ViT.check_params(p)
      if p["stem_type"] == "patchify":
          self.stem = ViTStemPatchify(3, p["hidden_d"], p["patch_size"])
      elif p["stem_type"] == "conv":
          ks, ws, ss = (
              p["c_stem_kernels"],
              p["c_stem_dims"],
              p["c_stem_strides"],
          )
          self.stem = ViTStemConv(3, ks, ws, ss)
      seq_len = (p["image_size"] // cfg.VIT.PATCH_SIZE) ** 2
      if p["cls_type"] == "token":
          self.class_token = Parameter(torch.zeros(1, 1, p["hidden_d"]))
          seq_len += 1
      else:
          self.class_token = None
      self.pos_embedding = Parameter(
          torch.zeros(seq_len, 1, p["hidden_d"])
      )
      self.encoder = ViTEncoder(
          p["n_layers"], p["hidden_d"], p["n_heads"], p["mlp_d"]
      )
      self.head = ViTHead(p["hidden_d"], p["num_classes"])
      init_weights_vit(self)
  
imports: import math
  import numpy
  import torch
  from pycls.core.config import cfg
  from pycls.models.blocks import activation, conv2d, conv2d_cx, layernorm, layernorm_cx, linear, linear_cx, MultiheadAttention, norm2d, norm2d_cx, patchify2d, patchify2d_cx
  from torch.nn import init, Module, Parameter
label_desc: Use image node_id 3 to create a new ViT object from inherited base classes: Module with example: obj = ViT(params)