class_docstr: Encoder for the I-JEPA model [0].
  
  Experimental: Support for I-JEPA is experimental, there might be breaking changes
  in the future.
  
  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]: Joint-Embedding Predictive Architecture, 2023, https://arxiv.org/abs/2301.08243
  - [1]: https://github.com/facebookresearch/ijepa
  
  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.
class_docstr_tok: ["Encoder","for","the","I-JEPA","model","[","0","]",".","Experimental",":","Support","for","I-JEPA","is","experimental",",","there","might","be","breaking","changes","in","the","future",".","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","]",":","Joint-Embedding","Predictive","Architecture",",","2023",",","https",":","\/\/arxiv.org\/abs\/2301.08243","-","[","1","]",":","https",":","\/\/github.com\/facebookresearch\/ijepa","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","."]
docstr: Converts images into patch tokens.
  
  Args:
      images:
          Tensor with shape (batch_size, channels, image_size, image_size).
  
  Returns:
      Tensor with shape (batch_size, sequence_length - 1, hidden_dim)
      containing the patch tokens.
docstr_tok: ["Converts","images","into","patch","tokens",".","Args",":","images",":","Tensor","with","shape","(","batch_size",",","channels",",","image_size",",","image_size",")",".","Returns",":","Tensor","with","shape","(","batch_size",",","sequence_length","-","1",",","hidden_dim",")","containing","the","patch","tokens","."]
code: def images_to_tokens(
      self, images: torch.Tensor, prepend_class_token: bool
  ) -> torch.Tensor:
      """Converts images into patch tokens.
  
      Args:
          images:
              Tensor with shape (batch_size, channels, image_size, image_size).
  
      Returns:
          Tensor with shape (batch_size, sequence_length - 1, hidden_dim)
          containing the patch tokens.
      """
      x = self.conv_proj(images)
      tokens = x.flatten(2).transpose(1, 2)
      if prepend_class_token:
          tokens = utils.prepend_class_token(tokens, self.class_token)
      return tokens
  
imports: import math
  from functools import partial
  from typing import Callable, List, Optional
  import numpy
  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 5 for calling the IJEPABackbone obj's underlying member method code with example usage: obj.images_to_tokens(images, prepend_class_token) and returns: tokens