code: def resize_rel_pos_bias_table_simple(
      rel_pos_bias,
      new_window_size: Tuple[int, int],
      new_bias_shape: Tuple[int, ...],
  ):
      dst_size = (
          new_window_size[0] * 2 - 1,
          new_window_size[1] * 2 - 1,
      )
      if rel_pos_bias.ndim == 3:
          # TF maxvit style (num_heads, H, W) bias shape, no extra tokens currently supported
          _, dst_h, dst_w = new_bias_shape
          num_attn_heads, src_h, src_w = rel_pos_bias.shape
          assert dst_h == dst_size[0] and dst_w == dst_size[1]
          if src_h != dst_h or src_w != dst_w:
              rel_pos_bias = torch.nn.functional.interpolate(
                  rel_pos_bias.unsqueeze(0),
                  size=dst_size,
                  mode="bicubic",
                  align_corners=False,
              ).squeeze(0)
      else:
          assert rel_pos_bias.ndim == 2
          # (num_pos, num_heads) (aka flat) bias shape
          dst_num_pos, _ = new_bias_shape
          src_num_pos, num_attn_heads = rel_pos_bias.shape
          num_extra_tokens = dst_num_pos - (dst_size[0] * dst_size[1])
          src_size = int((src_num_pos - num_extra_tokens) ** 0.5)
          src_size = (
              src_size,
              src_size,
          )  # FIXME could support non-equal src if argument passed
  
          if src_size[0] != dst_size[0] or src_size[1] != dst_size[1]:
              if num_extra_tokens:
                  extra_tokens = rel_pos_bias[-num_extra_tokens:, :]
                  rel_pos_bias = rel_pos_bias[:-num_extra_tokens, :]
              else:
                  extra_tokens = None
  
              rel_pos_bias = (
                  torch.nn.functional.interpolate(
                      rel_pos_bias.transpose(1, 0).reshape(
                          (1, -1, src_size[0], src_size[1])
                      ),
                      size=dst_size,
                      mode="bicubic",
                      align_corners=False,
                  )
                  .view(-1, dst_num_pos - num_extra_tokens)
                  .transpose(0, 1)
              )
  
              if extra_tokens is not None:
                  rel_pos_bias = torch.cat(
                      (rel_pos_bias, extra_tokens), dim=0
                  )
  
      return rel_pos_bias
  
imports: import math
  import os
  from typing import Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from .interpolate import RegularGridInterpolator
  from .mlp import Mlp
  from .weight_init import trunc_normal_
label_desc: Use image node_id 2 for calling a global function with example usage: resize_rel_pos_bias_table_simple(rel_pos_bias, new_window_size, new_bias_shape) and returns: rel_pos_bias