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: Returns encoded class and patch tokens from images.
  
  Args:
      images:
          Tensor with shape (batch_size, channels, image_size, image_size).
      idx_keep:
          Tensor with shape (batch_size, num_tokens_to_keep) where each
          entry is an index of the token to keep in the respective batch.
          If specified, only the indexed tokens will be passed to the
          encoder.
  
  Returns:
      Tensor with shape (batch_size, sequence_length, hidden_dim)
      containing the encoded class and patch tokens for every image.
docstr_tok: ["Returns","encoded","class","and","patch","tokens","from","images",".","Args",":","images",":","Tensor","with","shape","(","batch_size",",","channels",",","image_size",",","image_size",")",".","idx_keep",":","Tensor","with","shape","(","batch_size",",","num_tokens_to_keep",")","where","each","entry","is","an","index","of","the","token","to","keep","in","the","respective","batch",".","If","specified",",","only","the","indexed","tokens","will","be","passed","to","the","encoder",".","Returns",":","Tensor","with","shape","(","batch_size",",","sequence_length",",","hidden_dim",")","containing","the","encoded","class","and","patch","tokens","for","every","image","."]
code: def encode(
      self,
      images: torch.Tensor,
      idx_keep: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      """Returns encoded class and patch tokens from images.
  
      Args:
          images:
              Tensor with shape (batch_size, channels, image_size, image_size).
          idx_keep:
              Tensor with shape (batch_size, num_tokens_to_keep) where each
              entry is an index of the token to keep in the respective batch.
              If specified, only the indexed tokens will be passed to the
              encoder.
  
      Returns:
          Tensor with shape (batch_size, sequence_length, hidden_dim)
          containing the encoded class and patch tokens for every image.
  
      """
      out = self.images_to_tokens(images, prepend_class_token=True)
      return self.encoder(out, idx_keep)
  
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 4 for calling the MAEBackbone obj's underlying member method code with example usage: obj.encode(images, idx_keep) and returns: self