code: def resize_pos_embed(
      posemb, posemb_new, num_prefix_tokens=1, gs_new=()
  ):
      # Rescale the grid of position embeddings when loading from state_dict.
      # Adapted from:
      # https://github.com/google-research/vision_transformer/blob/
      #       00883dd691c63a6830751563748663526e811cee/vit_jax/checkpoint.py#L224
      # modify
      ntok_new = posemb_new.shape[1]
      if num_prefix_tokens:
          posemb_prefix, posemb_grid = (
              posemb[:, :num_prefix_tokens],
              posemb[0, num_prefix_tokens:],
          )
          # ntok_new -= num_prefix_tokens
      else:
          posemb_prefix, posemb_grid = posemb[:, :0], posemb[0]
      gs_old = int(math.sqrt(len(posemb_grid)))
      if ntok_new > gs_old**2:
          ntok_new -= gs_old**2
          # expand cls's pos embedding for prompt tokens
          posemb_prefix = posemb_prefix.expand(-1, ntok_new, -1)
      if not len(gs_new):  # backwards compatibility
          gs_new = [int(math.sqrt(ntok_new))] * 2
      assert len(gs_new) >= 2
  
      posemb_grid = posemb_grid.reshape(1, gs_old, gs_old, -1).permute(
          0, 3, 1, 2
      )
      posemb_grid = F.interpolate(
          posemb_grid, size=gs_new, mode="bicubic", align_corners=False
      )
      posemb_grid = posemb_grid.permute(0, 2, 3, 1).reshape(
          1, gs_new[0] * gs_new[1], -1
      )
      posemb = torch.cat([posemb_prefix, posemb_grid], dim=1)
      return posemb
  
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 a global function with example usage: resize_pos_embed(posemb, posemb_new, num_prefix_tokens, gs_new) and returns: posemb