class_docstr: Log-Coordinate Relative Position MLP
  Based on ideas presented in Swin-V2 paper (https://arxiv.org/abs/2111.09883)
  
  This impl covers the 'swin' implementation as well as two timm specific modes ('cr', and 'rw')
class_docstr_tok: ["Log-Coordinate","Relative","Position","MLP","Based","on","ideas","presented","in","Swin-V2","paper","(","https",":","\/\/arxiv.org\/abs\/2111.09883",")","This","impl","covers","the","'swin","'","implementation","as","well","as","two","timm","specific","modes","(","'cr","'",",","and","'rw","'",")"]
code: def __init__(
      self,
      window_size,
      num_heads=8,
      hidden_dim=128,
      prefix_tokens=0,
      mode="cr",
      pretrained_window_size=(0, 0),
  ):
      super().__init__()
      self.window_size = window_size
      self.window_area = self.window_size[0] * self.window_size[1]
      self.prefix_tokens = prefix_tokens
      self.num_heads = num_heads
      self.bias_shape = (self.window_area,) * 2 + (num_heads,)
      if mode == "swin":
          self.bias_act = nn.Sigmoid()
          self.bias_gain = 16
          mlp_bias = (True, False)
      else:
          self.bias_act = nn.Identity()
          self.bias_gain = None
          mlp_bias = True
  
      self.mlp = Mlp(
          2,  # x, y
          hidden_features=hidden_dim,
          out_features=num_heads,
          act_layer=nn.ReLU,
          bias=mlp_bias,
          drop=(0.125, 0.0),
      )
  
      self.register_buffer(
          "relative_position_index",
          gen_relative_position_index(window_size).view(-1),
          persistent=False,
      )
  
      # get relative_coords_table
      self.register_buffer(
          "rel_coords_log",
          gen_relative_log_coords(
              window_size, pretrained_window_size, mode=mode
          ),
          persistent=False,
      )
  
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 1 to create a new RelPosMlp object from inherited base classes: nn with example: obj = RelPosMlp(window_size, num_heads, hidden_dim, prefix_tokens, mode, pretrained_window_size)