class_docstr: Attention layer for Encoder block.
  
  Args:
      dim (int): Dimension for the input vector.
      num_heads (int): Number of parallel attention heads.
      qkv_bias (bool): Enable bias for qkv if True. Default: False.
      qk_scale (float): Override default qk scale of head_dim ** -0.5 if set.
      attn_drop (float): Drop rate for attention output weights.
          Default: 0.
      proj_drop (float): Drop rate for output weights. Default: 0.
class_docstr_tok: ["Attention","layer","for","Encoder","block",".","Args",":","dim","(","int",")",":","Dimension","for","the","input","vector",".","num_heads","(","int",")",":","Number","of","parallel","attention","heads",".","qkv_bias","(","bool",")",":","Enable","bias","for","qkv","if","True",".","Default",":","False",".","qk_scale","(","float",")",":","Override","default","qk","scale","of","head_dim","*","*","-0.5","if","set",".","attn_drop","(","float",")",":","Drop","rate","for","attention","output","weights",".","Default",":","0.","proj_drop","(","float",")",":","Drop","rate","for","output","weights",".","Default",":","0","."]
code: def forward(self, x):
      b, n, c = x.shape
      qkv = (
          self.qkv(x)
          .reshape(b, n, 3, self.num_heads, c // self.num_heads)
          .permute(2, 0, 3, 1, 4)
      )
      q, k, v = qkv[0], qkv[1], qkv[2]
  
      attn = (q @ k.transpose(-2, -1)) * self.scale
      attn = attn.softmax(dim=-1)
      attn = self.attn_drop(attn)
  
      x = (attn @ v).transpose(1, 2).reshape(b, n, c)
      x = self.proj(x)
      x = self.proj_drop(x)
      return x
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from annotator.uniformer.mmcv.cnn import Conv2d, Linear, build_activation_layer, build_norm_layer, constant_init, kaiming_init, normal_init
  from annotator.uniformer.mmcv.runner import _load_checkpoint
  from annotator.uniformer.mmcv.utils.parrots_wrapper import _BatchNorm
  from annotator.uniformer.mmseg.utils import get_root_logger
  from ..builder import BACKBONES
  from ..utils import DropPath, trunc_normal_
label_desc: Use image node_id 2 for calling the Attention obj's underlying member method code with example usage: obj.forward(x) and returns: x