def from_vit_encoder(cls, vit_encoder, num_patches):
        """Creates an I-JEPA predictor backbone (multi-head attention and layernorm) from a torchvision ViT encoder.

        Args:
            vit_encoder: The Vision Transformer encoder from torchvision.
            num_patches: The number of patches (tokens).

        Returns:
            IJEPAPredictor: An I-JEPA predictor backbone initialized from the ViT encoder.
        """

        # Create a new instance with dummy values as they will be overwritten
        # by the copied vit_encoder attributes
        encoder = cls(
            seq_length=1,
            num_layers=1,
            num_heads=1,
            hidden_dim=1,
            predictor_embed_dim=768,
            mlp_dim=768,
            num_patches=num_patches,
            dropout=0,
            attention_dropout=0,
        )

        # Copy attributes from the ViT encoder
        encoder.layers = vit_encoder.layers
        encoder.ln = vit_encoder.ln

        return encoder
Creates an I-JEPA predictor backbone (multi-head attention and layernorm) from a torchvision ViT encoder.

        Args:
            vit_encoder: The Vision Transformer encoder from torchvision.
            num_patches: The number of patches (tokens).

        Returns:
            IJEPAPredictor: An I-JEPA predictor backbone initialized from the ViT encoder.
        
lightly/models/modules/ijepa.py