class_docstr: Relative Self-Attention similar to Swin V1. Implementation inspired by Timms Swin V1 implementation.
  Args:
      in_channels (`int`):
          Number of input channels.
      num_heads (`int`):
          Number of attention heads. Default 32
      grid_window_size (`Tuple[int, int]`):
          Grid/Window size to be utilized. Default (7, 7)
      attn_drop (`float`):
          Dropout ratio of attention weight. Default: 0.0
      drop (`float`):
          Dropout ratio of output. Default: 0.0
docstr: Constructor method 
code: def __init__(
      self,
      in_channels: int,
      num_heads: int = 32,
      grid_window_size: Tuple[int, int] = (7, 7),
      attn_drop: float = 0.0,
      drop: float = 0.0,
  ) -> None:
      """Constructor method"""
      # Call super constructor
      super().__init__()
      # Save parameters
      self.in_channels: int = in_channels
      self.num_heads: int = num_heads
      self.grid_window_size: Tuple[int, int] = grid_window_size
      self.scale: float = num_heads**-0.5
      self.attn_area: int = grid_window_size[0] * grid_window_size[1]
      # Init layers
      self.qkv_mapping = nn.Linear(
          in_features=in_channels,
          out_features=3 * in_channels,
          bias=True,
      )
      self.attn_drop = nn.Dropout(p=attn_drop)
      self.proj = nn.Linear(
          in_features=in_channels, out_features=in_channels, bias=True
      )
      self.proj_drop = nn.Dropout(p=drop)
      self.softmax = nn.Softmax(dim=-1)
      # Define a parameter table of relative position bias, shape: 2*Wh-1 * 2*Ww-1, nH
      self.relative_position_bias_table = nn.Parameter(
          torch.zeros(
              (2 * grid_window_size[0] - 1)
              * (2 * grid_window_size[1] - 1),
              num_heads,
          )
      )
  
      # Get pair-wise relative position index for each token inside the window
      self.register_buffer(
          "relative_position_index",
          get_relative_position_index(
              grid_window_size[0], grid_window_size[1]
          ),
      )
      # Init relative positional bias
      trunc_normal_(self.relative_position_bias_table, std=0.02)
  
file_path: towhee/towhee/models/layers/relative_self_attention.py
imports: from typing import Tuple
  from towhee.models.utils.weight_init import trunc_normal_
  from towhee.models.utils.get_relative_position_index import get_relative_position_index
  from torch import nn
  import torch
label_desc: Use image node_id 1 to create a new RelativeSelfAttention object from inherited base classes: nn with example: obj = RelativeSelfAttention(in_channels, num_heads, grid_window_size, attn_drop, drop)