docstr:     Attention score calculation.
  Parameters
  ----------
  src: torch.Tensor, shape=[B, D]
  tgt: torch.Tensor, shape=[B, N, D]
  coverage: torch.Tensor, shape=[B, N, D]
  Returns
  -------
  aligns: torch.Tensor, shape=[B, N]
docstr_tok: ["Attention","score","calculation",".","Parameters","--","--","--","--","--","src",":","torch.Tensor",",","shape=","[","B",",","D","]","tgt",":","torch.Tensor",",","shape=","[","B",",","N",",","D","]","coverage",":","torch.Tensor",",","shape=","[","B",",","N",",","D","]","Returns","--","--","--","-","aligns",":","torch.Tensor",",","shape=","[","B",",","N","]"]
code: def _calculate_aligns(self, src, tgt, coverage=None):
      """
          Attention score calculation.
      Parameters
      ----------
      src: torch.Tensor, shape=[B, D]
      tgt: torch.Tensor, shape=[B, N, D]
      coverage: torch.Tensor, shape=[B, N, D]
      Returns
      -------
      aligns: torch.Tensor, shape=[B, N]
      """
      if self.attn_type == "mlp":
          src = self.query_in(src)
          tgt = self.memory_in(tgt)
          aligns = src.unsqueeze(1) + tgt
          if coverage is not None:
              assert len(coverage.shape) == 3
              assert coverage.shape[-1] == self.hidden_size
              aligns += coverage
          aligns = torch.tanh(aligns)
          aligns = self.out(aligns)
          aligns = aligns.view(aligns.shape[0], aligns.shape[1])
      elif self.attn_type == "general" or self.attn_type == "dot":
          if coverage:
              assert tgt.shape == coverage.shape
              tgt = tgt + coverage
              tgt = torch.tanh(tgt)
  
          if self.attn_type == "general":
              src = self.query2memory(src)
          aligns = torch.bmm(src.unsqueeze(1), tgt.transpose(1, 2))
          aligns = aligns.squeeze(1).contiguous()
      else:
          raise NotImplementedError()
      return aligns
  
imports: import torch
  import torch.nn
label_desc: Use image node_id 3 for calling the Attention obj's underlying member method code with example usage: obj._calculate_aligns(src, tgt, coverage) and returns: aligns