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):
      nn.init.xavier_uniform_(self.in_proj_weight_q)
      # in_proj_weight_kv has shape [2 * hidden, hidden] but it should be
      # initialized like a [hidden, hidden] matrix.
      # sqrt(6 / (hidden + hidden)) / sqrt(6 / (2 * hidden + hidden)) = sqrt(1.5)
      # therefore xavier_uniform gain should be set to sqrt(1.5).
      nn.init.xavier_uniform_(
          self.in_proj_weight_kv, gain=math.sqrt(1.5)
      )
      nn.init.xavier_uniform_(self.out_proj_weight)
      if self.bias:
          nn.init.constant_(self.in_proj_bias_q, 0.0)
          nn.init.constant_(self.in_proj_bias_kv, 0.0)
          nn.init.constant_(self.out_proj_bias, 0.0)
      if self.include_norm_add:
          if self.impl == "fast":
              nn.init.ones_(self.lyr_nrm_gamma_weights)
              nn.init.zeros_(self.lyr_nrm_beta_weights)
          else:
              self.lyr_nrm.reset_parameters()
  
file_path: apex/apex/contrib/multihead_attn/encdec_multihead_attn.py
imports: import math
  import torch
  from torch import nn
  from torch.nn import Parameter
  import torch.nn.functional
  from .encdec_multihead_attn_func import encdec_attn_func
  from .fast_encdec_multihead_attn_func import fast_encdec_attn_func
  from .fast_encdec_multihead_attn_norm_add_func import fast_encdec_attn_norm_add_func
  from apex.normalization.fused_layer_norm import FusedLayerNorm
label_desc: Use image node_id 2 for calling the EncdecMultiheadAttn obj's underlying member method code with example usage: obj.reset_parameters() without return types