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
          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 math
  from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from torch.nn import Parameter
  from fairseq import utils
  from fairseq.modules.fairseq_dropout import FairseqDropout
  from fairseq.modules.quant_noise import quant_noise
  from fairseq.models.fairseq_incremental_decoder import FairseqIncrementalDecoder
label_desc: Use image node_id 3 for calling the MultiheadAttention obj's underlying member method code with example usage: obj.reset_parameters() without return types