class_docstr: An implementation of the absolute position embedding in PVT.
  
  Args:
      pos_shape (int): The shape of the absolute position embedding.
      pos_dim (int): The dimension of the absolute position embedding.
      drop_rate (float): Probability of an element to be zeroed.
          Default: 0.0.
class_docstr_tok: ["An","implementation","of","the","absolute","position","embedding","in","PVT",".","Args",":","pos_shape","(","int",")",":","The","shape","of","the","absolute","position","embedding",".","pos_dim","(","int",")",":","The","dimension","of","the","absolute","position","embedding",".","drop_rate","(","float",")",":","Probability","of","an","element","to","be","zeroed",".","Default",":","0.0","."]
docstr: Resize pos_embed weights.
  
  Resize pos_embed using bilinear interpolate method.
  
  Args:
      pos_embed (torch.Tensor): Position embedding weights.
      input_shape (tuple): Tuple for (downsampled input image height,
          downsampled input image width).
      mode (str): Algorithm used for upsampling:
          ``'nearest'`` | ``'linear'`` | ``'bilinear'`` | ``'bicubic'`` |
          ``'trilinear'``. Default: ``'bilinear'``.
  
  Return:
      torch.Tensor: The resized pos_embed of shape [B, L_new, C].
docstr_tok: ["Resize","pos_embed","weights",".","Resize","pos_embed","using","bilinear","interpolate","method",".","Args",":","pos_embed","(","torch.Tensor",")",":","Position","embedding","weights",".","input_shape","(","tuple",")",":","Tuple","for","(","downsampled","input","image","height",",","downsampled","input","image","width",")",".","mode","(","str",")",":","Algorithm","used","for","upsampling",":","``","'nearest","'","``","|","``","'linear","'","``","|","``","'bilinear","'","``","|","``","'bicubic","'","``","|","``","'trilinear","'","``",".","Default",":","``","'bilinear","'","``",".","Return",":","torch.Tensor",":","The","resized","pos_embed","of","shape","[","B",",","L_new",",","C","]","."]
code: def resize_pos_embed(self, pos_embed, input_shape, mode="bilinear"):
      """Resize pos_embed weights.
  
      Resize pos_embed using bilinear interpolate method.
  
      Args:
          pos_embed (torch.Tensor): Position embedding weights.
          input_shape (tuple): Tuple for (downsampled input image height,
              downsampled input image width).
          mode (str): Algorithm used for upsampling:
              ``'nearest'`` | ``'linear'`` | ``'bilinear'`` | ``'bicubic'`` |
              ``'trilinear'``. Default: ``'bilinear'``.
  
      Return:
          torch.Tensor: The resized pos_embed of shape [B, L_new, C].
      """
      assert pos_embed.ndim == 3, "shape of pos_embed must be [B, L, C]"
      pos_h, pos_w = self.pos_shape
      pos_embed_weight = pos_embed[:, (-1 * pos_h * pos_w) :]
      pos_embed_weight = (
          pos_embed_weight.reshape(1, pos_h, pos_w, self.pos_dim)
          .permute(0, 3, 1, 2)
          .contiguous()
      )
      pos_embed_weight = F.interpolate(
          pos_embed_weight, size=input_shape, mode=mode
      )
      pos_embed_weight = (
          torch.flatten(pos_embed_weight, 2)
          .transpose(1, 2)
          .contiguous()
      )
      pos_embed = pos_embed_weight
  
      return pos_embed
  
imports: import math
  import warnings
  from collections import OrderedDict
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Conv2d, build_activation_layer, build_norm_layer
  from mmcv.cnn.bricks.drop import build_dropout
  from mmcv.cnn.bricks.transformer import MultiheadAttention
  from mmengine.logging import MMLogger
  from mmengine.model import BaseModule, ModuleList, Sequential, constant_init, normal_init, trunc_normal_init
  from mmengine.model.weight_init import trunc_normal_
  from mmengine.runner.checkpoint import CheckpointLoader, load_state_dict
  from torch.nn.modules.utils import _pair
  from mmdet.registry import MODELS
  from ..layers import PatchEmbed, nchw_to_nlc, nlc_to_nchw
label_desc: Use image node_id 3 for calling the AbsolutePositionEmbedding obj's underlying member method code with example usage: obj.resize_pos_embed(pos_embed, input_shape, mode) and returns: pos_embed