# `L2PViT`

### *class* capymoa.ocl.strategy.l2p.L2PViT[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/ocl/strategy/l2p.py#L24)

Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC)

Abstract interface for vision transformer backbones used in L2P.

#### *abstract* forward_encoder(prompts: [Tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor), patch_embed: [Tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor)) → [Tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/ocl/strategy/l2p.py#L42)

Encode the patch embeddings with the given prompts.

* **Parameters:**
  * **prompts** – A tensor of shape (batch_size, prompt_length, embed_dim)
  * **patch_embed** – A tensor of shape (batch_size, num_patches + 1, embed_dim)
* **Returns:**
  A tensor of shape (batch_size, num_patches + 1 + prompt_length, embed_dim)

#### *abstract* forward_query(patch_embed: [Tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor)) → [Tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/ocl/strategy/l2p.py#L51)

Get the encoded query embedding from the patch embeddings.

* **Parameters:**
  **patch_embed** – A tensor of shape (batch_size, num_patches + 1, embed_dim)
* **Returns:**
  A tensor of shape (batch_size, embed_dim)

#### *abstract* get_embedding_size() → [int](https://docs.python.org/3/builtins/functions.html#int)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/ocl/strategy/l2p.py#L27)

Get the dimension of the patch embeddings.

* **Returns:**
  The embedding dimension.

#### *abstract* get_patch_embed(pixel_values: [Tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor)) → [Tensor](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/ocl/strategy/l2p.py#L34)

Turn pixel values into patch embeddings.

* **Parameters:**
  **pixel_values** – A tensor of shape (batch_size, channels, height, width)
* **Returns:**
  A tensor of shape (batch_size, num_patches + 1, embed_dim)
