code: def _vision_transformer(
      patch_size: int,
      num_layers: int,
      num_heads: int,
      hidden_dim: int,
      mlp_dim: int,
      weights: Optional[WeightsEnum],
      progress: bool,
      **kwargs: Any,
  ) -> VisionTransformer:
      if weights is not None:
          _ovewrite_named_param(
              kwargs, "num_classes", len(weights.meta["categories"])
          )
          assert (
              weights.meta["min_size"][0] == weights.meta["min_size"][1]
          )
          _ovewrite_named_param(
              kwargs, "image_size", weights.meta["min_size"][0]
          )
      image_size = kwargs.pop("image_size", 224)
  
      model = VisionTransformer(
          image_size=image_size,
          patch_size=patch_size,
          num_layers=num_layers,
          num_heads=num_heads,
          hidden_dim=hidden_dim,
          mlp_dim=mlp_dim,
          **kwargs,
      )
  
      if weights:
          model.load_state_dict(
              weights.get_state_dict(progress=progress, check_hash=True)
          )
  
      return model
  
imports: import math
  from collections import OrderedDict
  from functools import partial
  from typing import Any, Callable, Dict, List, NamedTuple, Optional
  import torch
  import torch.nn
  from ..ops.misc import Conv2dNormActivation, MLP
  from ..transforms._presets import ImageClassification, InterpolationMode
  from ..utils import _log_api_usage_once
  from ._api import register_model, Weights, WeightsEnum
  from ._meta import _IMAGENET_CATEGORIES
  from ._utils import _ovewrite_named_param, handle_legacy_interface
label_desc: Use image node_id 1 for calling a global function with example usage: _vision_transformer(patch_size, num_layers, num_heads, hidden_dim, mlp_dim, weights, progress) and returns: model