def from_vit(cls, vit: vision_transformer.VisionTransformer):
        """Creates a IJEPABackbone 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,
        )

        # Copy attributes from the ViT model
        backbone.conv_proj = vit.conv_proj
        backbone.class_token = vit.class_token
        backbone.seq_length = vit.seq_length
        backbone.heads = vit.heads
        backbone.encoder = IJEPAEncoder.from_vit_encoder(vit.encoder)

        return backbone
Creates a IJEPABackbone from a torchvision ViT model.
lightly/models/modules/ijepa.py