class_docstr: Bottleneck Attention
  Paper: `Bottleneck Transformers for Visual Recognition` - https://arxiv.org/abs/2101.11605
  
  The internal dimensions of the attention module are controlled by the interaction of several arguments.
    * the output dimension of the module is specified by dim_out, which falls back to input dim if not set
    * the value (v) dimension is set to dim_out // num_heads, the v projection determines the output dim
    * the query and key (qk) dimensions are determined by
      * num_heads * dim_head if dim_head is not None
      * num_heads * (dim_out * attn_ratio // num_heads) if dim_head is None
    * as seen above, attn_ratio determines the ratio of q and k relative to the output if dim_head not used
  
  Args:
      dim (int): input dimension to the module
      dim_out (int): output dimension of the module, same as dim if not set
      stride (int): output stride of the module, avg pool used if stride == 2 (default: 1).
      num_heads (int): parallel attention heads (default: 4)
      dim_head (int): dimension of query and key heads, calculated from dim_out * attn_ratio // num_heads if not set
      qk_ratio (float): ratio of q and k dimensions to output dimension when dim_head not set. (default: 1.0)
      qkv_bias (bool): add bias to q, k, and v projections
      scale_pos_embed (bool): scale the position embedding as well as Q @ K
class_docstr_tok: ["Bottleneck","Attention","Paper",":","`","Bottleneck","Transformers","for","Visual","Recognition","`","-","https",":","\/\/arxiv.org\/abs\/2101.11605","The","internal","dimensions","of","the","attention","module","are","controlled","by","the","interaction","of","several","arguments",".","*","the","output","dimension","of","the","module","is","specified","by","dim_out",",","which","falls","back","to","input","dim","if","not","set","*","the","value","(","v",")","dimension","is","set","to","dim_out","\/\/","num_heads",",","the","v","projection","determines","the","output","dim","*","the","query","and","key","(","qk",")","dimensions","are","determined","by","*","num_heads","*","dim_head","if","dim_head","is","not","None","*","num_heads","*","(","dim_out","*","attn_ratio","\/\/","num_heads",")","if","dim_head","is","None","*","as","seen","above",",","attn_ratio","determines","the","ratio","of","q","and","k","relative","to","the","output","if","dim_head","not","used","Args",":","dim","(","int",")",":","input","dimension","to","the","module","dim_out","(","int",")",":","output","dimension","of","the","module",",","same","as","dim","if","not","set","stride","(","int",")",":","output","stride","of","the","module",",","avg","pool","used","if","stride","==","2","(","default",":","1",")",".","num_heads","(","int",")",":","parallel","attention","heads","(","default",":","4",")","dim_head","(","int",")",":","dimension","of","query","and","key","heads",",","calculated","from","dim_out","*","attn_ratio","\/\/","num_heads","if","not","set","qk_ratio","(","float",")",":","ratio","of","q","and","k","dimensions","to","output","dimension","when","dim_head","not","set",".","(","default",":","1.0",")","qkv_bias","(","bool",")",":","add","bias","to","q",",","k",",","and","v","projections","scale_pos_embed","(","bool",")",":","scale","the","position","embedding","as","well","as","Q","@","K"]
code: def reset_parameters(self):
      trunc_normal_(
          self.qkv.weight, std=self.qkv.weight.shape[1] ** -0.5
      )  # fan-in
      trunc_normal_(self.pos_embed.height_rel, std=self.scale)
      trunc_normal_(self.pos_embed.width_rel, std=self.scale)
  
file_path: pytorch-image-models/timm/layers/bottleneck_attn.py
imports: from typing import List
  import torch
  import torch.nn
  import torch.nn.functional
  from .helpers import to_2tuple, make_divisible
  from .weight_init import trunc_normal_
  from .trace_utils import _assert
label_desc: Use image node_id 2 for calling the BottleneckAttn obj's underlying member method code with example usage: obj.reset_parameters() without return types