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: Forward pass.
  Args:
      data (`torch.Tensor`):
          Input tensor of the shape [B_, N, C].
  Returns:
      output (`torch.Tensor`):
          Output tensor of the shape [B_, N, C].
code: def forward(self, data: torch.Tensor) -> torch.Tensor:
      """
      Forward pass.
      Args:
          data (`torch.Tensor`):
              Input tensor of the shape [B_, N, C].
      Returns:
          output (`torch.Tensor`):
              Output tensor of the shape [B_, N, C].
      """
      # Get shape of input
      b_, n, _ = data.shape
      # Perform query key value mapping
      qkv = (
          self.qkv_mapping(data)
          .reshape(b_, n, 3, self.num_heads, -1)
          .permute(2, 0, 3, 1, 4)
      )
      q, k, v = qkv.unbind(0)
      # Scale query
      q = q * self.scale
      # Compute attention maps
      attn = self.softmax(
          q @ k.transpose(-2, -1) + self._get_relative_positional_bias()
      )
      # Map value with attention maps
      output = (attn @ v).transpose(1, 2).reshape(b_, n, -1)
      # Perform final projection and dropout
      output = self.proj(output)
      output = self.proj_drop(output)
      return output
  
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 3 for calling the RelativeSelfAttention obj's underlying member method code with example usage: obj.forward(data) and returns: output