class_docstr: Multi-Head Attention layer of Transformer.
  Args:
      n_head (int): number of heads
      n_feat (int): size of the features
      dropout_rate (float): dropout rate
class_docstr_tok: ["Multi-Head","Attention","layer","of","Transformer",".","Args",":","n_head","(","int",")",":","number","of","heads","n_feat","(","int",")",":","size","of","the","features","dropout_rate","(","float",")",":","dropout","rate"]
docstr: Compute attention context vector.
  Args:
      value (torch.Tensor): (batch, time2, size)
      scores(torch.Tensor): (batch, time1, time2)
      mask(torch.Tensor): (batch, time1, time2)
  returns:
      value (torch.Tensor): transformed `value` (batch, time2, d_model) weighted by the attention scores
docstr_tok: ["Compute","attention","context","vector",".","Args",":","value","(","torch.Tensor",")",":","(","batch",",","time2",",","size",")","scores","(","torch.Tensor",")",":","(","batch",",","time1",",","time2",")","mask","(","torch.Tensor",")",":","(","batch",",","time1",",","time2",")","returns",":","value","(","torch.Tensor",")",":","transformed","`","value","`","(","batch",",","time2",",","d_model",")","weighted","by","the","attention","scores"]
code: def forward_attention(self, value, scores, mask):
      """Compute attention context vector.
      Args:
          value (torch.Tensor): (batch, time2, size)
          scores(torch.Tensor): (batch, time1, time2)
          mask(torch.Tensor): (batch, time1, time2)
      returns:
          value (torch.Tensor): transformed `value` (batch, time2, d_model) weighted by the attention scores
      """
      n_batch = value.size(0)
      if mask is not None:
          mask = mask.unsqueeze(1)  # (batch, 1, time1, time2)
          scores = scores.masked_fill(mask, -10000.0)
          attn = torch.softmax(scores, dim=-1).masked_fill(
              mask, 0.0
          )  # (batch, head, time1, time2)
      else:
          attn = torch.softmax(
              scores, dim=-1
          )  # (batch, head, time1, time2)
  
      p_attn = self.dropout(attn)
      x = torch.matmul(p_attn, value)  # (batch, head, time1, d_k)
      x = x.transpose(1, 2).reshape(
          n_batch, -1, self.h * self.d_k
      )  # (batch, time1, d_model)
  
      return self.linear_out(x)
  
imports: import math
  from functools import lru_cache
  from typing import List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from nemo.utils import avoid_float16_autocast_context
label_desc: Use image node_id 3 for calling the MultiHeadAttention obj's underlying member method code with example usage: obj.forward_attention(value, scores, mask) and returns: self