class_docstr: Multi-headed attention.
  
  See "Attention Is All You Need" for more details.
class_docstr_tok: ["Multi-headed","attention",".","See","``","Attention","Is","All","You","Need","''","for","more","details","."]
code: def reset_parameters(self):
      if self.qkv_same_dim:
          # Empirically observed the convergence to be much better with
          # the scaled initialization
          if self.self_attention:
              nn.init.xavier_uniform_(
                  self.qkv_proj.weight, gain=1 / math.sqrt(2)
              )
          else:
              nn.init.xavier_uniform_(
                  self.k_proj.weight, gain=1 / math.sqrt(2)
              )
              nn.init.xavier_uniform_(
                  self.v_proj.weight, gain=1 / math.sqrt(2)
              )
              nn.init.xavier_uniform_(
                  self.q_proj.weight, gain=1 / math.sqrt(2)
              )
      else:
          nn.init.xavier_uniform_(self.k_proj.weight)
          nn.init.xavier_uniform_(self.v_proj.weight)
          nn.init.xavier_uniform_(self.q_proj.weight)
  
      nn.init.xavier_uniform_(self.out_proj.weight)
      if self.out_proj.bias is not None:
          nn.init.constant_(self.out_proj.bias, 0.0)
      if self.bias_k is not None:
          nn.init.xavier_normal_(self.bias_k)
      if self.bias_v is not None:
          nn.init.xavier_normal_(self.bias_v)
  
imports: import __init__
  import math
  import uuid
  from typing import Dict, Optional, List
  import torch
  from torch import Tensor, nn
  from torch.nn import Parameter, LayerNorm, Dropout
  from csrc.pytorch import util
  from csrc.pytorch.layer_base import TransformerEmbeddingLayerBase, TransformerEncoderLayerBase, TransformerDecoderLayerBase
  from csrc.pytorch.quantization import QuantLinear, TensorQuantizer, act_quant_config, weight_quant_config, out_quant_config, emb_quant_config
label_desc: Use image node_id 4 for calling the MultiheadAttention obj's underlying member method code with example usage: obj.reset_parameters() without return types