code: def forward(self, query, key, value, mask=None):
      n, seq_len = mask.size()
      logits = torch.matmul(query.permute(0, 2, 1), key) * self.scale
  
      if mask is not None:
          mask = mask.view(n, 1, seq_len)
          logits = logits.masked_fill(mask, float("-inf"))
  
      weights = F.softmax(logits, dim=2)
  
      glimpse = torch.matmul(weights, value.transpose(1, 2))
  
      glimpse = glimpse.permute(0, 2, 1).contiguous()
  
      return glimpse
  
imports: import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the DotProductAttentionLayer obj's underlying member method code with example usage: obj.forward(query, key, value, mask) and returns: glimpse