class_docstr: Backbone for the Masked Autoencoder model [0].
  
  Converts images into patches and encodes them. Code inspired by [1].
  Note that this implementation uses a learned positional embedding while [0]
  uses a fixed positional embedding.
  
  - [0]: Masked Autoencoder, 2021, https://arxiv.org/abs/2111.06377
  - [1]: https://github.com/facebookresearch/mae
  - [2]: Early Convolutions Help Transformers See Better, 2021, https://arxiv.org/abs/2106.14881.
  
  Attributes:
      image_size:
          Input image size.
      patch_size:
          Width and height of the image patches. image_size must be a multiple
          of patch_size.
      num_layers:
          Number of transformer blocks.
      num_heads:
          Number of attention heads.
      hidden_dim:
          Dimension of the input and output tokens.
      mlp_dim:
          Dimension of the MLP in the transformer block.
      dropout:
          Percentage of elements set to zero after the MLP in the transformer.
      attention_dropout:
          Percentage of elements set to zero after the attention head.
      num_classes:
          Number of classes for the classification head. Currently not used.
      representation_size:
          If specified, an additional linear layer is added before the
          classification head to change the token dimension from hidden_dim
          to representation_size. Currently not used.
      norm_layer:
          Callable that creates a normalization layer.
      conv_stem_configs:
          If specified, a convolutional stem is added at the beggining of the
          network following [2]. Not used in the original Masked Autoencoder
          paper [0].
docstr: Creates a MAEBackbone from a torchvision ViT model.
docstr_tok: ["Creates","a","MAEBackbone","from","a","torchvision","ViT","model","."]
code: def from_vit(
      cls, vit: vision_transformer.VisionTransformer
  ) -> MAEBackbone:
      """Creates a MAEBackbone from a torchvision ViT model."""
      # Create a new instance with dummy values as they will be overwritten
      # by the copied vit_encoder attributes
      backbone = cls(
          image_size=vit.image_size,
          patch_size=vit.patch_size,
          num_layers=1,
          num_heads=1,
          hidden_dim=vit.hidden_dim,
          mlp_dim=vit.mlp_dim,
          dropout=vit.dropout,
          attention_dropout=vit.attention_dropout,
          num_classes=vit.num_classes,
          representation_size=vit.representation_size,
          norm_layer=vit.norm_layer,
      )
      backbone.conv_proj = vit.conv_proj
      backbone.class_token = vit.class_token
      backbone.seq_length = vit.seq_length
      backbone.heads = vit.heads
      backbone.encoder = MAEEncoder.from_vit_encoder(vit.encoder)
      return backbone
  
imports: from __future__ import annotations
  import math
  from functools import partial
  from typing import Callable, List, Optional
  import torch
  import torch.nn
  from torchvision.models import vision_transformer
  from torchvision.models.vision_transformer import ConvStemConfig
  from lightly.models import utils
label_desc: Use image node_id 2 for calling the MAEBackbone obj's underlying member method code with example usage: obj.from_vit(cls, vit) and returns: backbone