class_docstr: Visual Transformer with Prompt. This class add prompts to a visual
  transformer to implement the Method Learning to Prompt (L2P)
  
  Implementation based on VisionTransformer from timm library
class_docstr_tok: ["Visual","Transformer","with","Prompt",".","This","class","add","prompts","to","a","visual","transformer","to","implement","the","Method","Learning","to","Prompt","(","L2P",")","Implementation","based","on","VisionTransformer","from","timm","library"]
code: def forward_features(
      self, x, task_id=-1, cls_features=None, train=False
  ):
      x = x.float()
      x = self.patch_embed(x)
  
      if hasattr(self, "prompt"):
          if self.use_prompt_mask and train:
              start = task_id * self.prompt.top_k
              end = (task_id + 1) * self.prompt.top_k
              single_prompt_mask = torch.arange(start, end).to(x.device)
              prompt_mask = single_prompt_mask.unsqueeze(0).expand(
                  x.shape[0], -1
              )
              if end > self.prompt.pool_size:
                  prompt_mask = None
          else:
              prompt_mask = None
          res = self.prompt(
              x, prompt_mask=prompt_mask, cls_features=cls_features
          )
          self.total_prompt_len = res["total_prompt_len"]
          x = res["prompted_embedding"]
      else:
          res = dict()
      if self.cls_token is not None:
          x = torch.cat(
              (self.cls_token.expand(x.shape[0], -1, -1), x), dim=1
          )
  
      x = self.pos_drop(x + self.pos_embed)
  
      if self.grad_checkpointing and not torch.jit.is_scripting():
          x = checkpoint_seq(self.blocks, x)
      else:
          x = self.blocks(x)
  
      x = self.norm(x)
      res["x"] = x
  
      return res
  
file_path: avalanche/avalanche/models/timm_vit.py
imports: import math
  import re
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from avalanche.models import Prompt
label_desc: Use image node_id 2 for calling the ViTWithPrompt obj's underlying member method code with example usage: obj.forward_features(x, task_id, cls_features, train) and returns: res