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 __init__(
      self,
      dim,
      num_heads=8,
      qkv_bias=False,
      qk_scale=None,
      attn_drop=0.0,
      proj_drop=0.0,
  ):
      super(Attention, self).__init__()
      self.num_heads = num_heads
      head_dim = dim // num_heads
      self.scale = qk_scale or head_dim**-0.5
  
      self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
      self.attn_drop = nn.Dropout(attn_drop)
      self.proj = Linear(dim, dim)
      self.proj_drop = nn.Dropout(proj_drop)
  
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 1 to create a new Attention object from inherited base classes: nn with example: obj = Attention(dim, num_heads, qkv_bias, qk_scale, attn_drop, proj_drop)