class_docstr: Receives bert contextual embeddings of a text, extracts all the
  possible mentions in that text. 
class_docstr_tok: ["Receives","bert","contextual","embeddings","of","a","text",",","extracts","all","the","possible","mentions","in","that","text","."]
docstr: Calculates attention scores for each of the mentions.
  
  Args:
      bert_out (torch.Tensor): [n_subwords, bert_emb], bert embeddings
          for each of the subwords in the document
      word_starts (torch.Tensor): [n_words], start indices of words
      word_ends (torch.Tensor): [n_words], end indices of words
  
  Returns:
      torch.Tensor: [description]
docstr_tok: ["Calculates","attention","scores","for","each","of","the","mentions",".","Args",":","bert_out","(","torch.Tensor",")",":","[","n_subwords",",","bert_emb","]",",","bert","embeddings","for","each","of","the","subwords","in","the","document","word_starts","(","torch.Tensor",")",":","[","n_words","]",",","start","indices","of","words","word_ends","(","torch.Tensor",")",":","[","n_words","]",",","end","indices","of","words","Returns",":","torch.Tensor",":","[","description","]"]
code: def _attn_scores(
      self,
      bert_out: torch.Tensor,
      word_starts: torch.Tensor,
      word_ends: torch.Tensor,
  ) -> torch.Tensor:
      """Calculates attention scores for each of the mentions.
  
      Args:
          bert_out (torch.Tensor): [n_subwords, bert_emb], bert embeddings
              for each of the subwords in the document
          word_starts (torch.Tensor): [n_words], start indices of words
          word_ends (torch.Tensor): [n_words], end indices of words
  
      Returns:
          torch.Tensor: [description]
      """
      n_subtokens = len(bert_out)
      n_words = len(word_starts)
  
      # [n_mentions, n_subtokens]
      # with 0 at positions belonging to the words and -inf elsewhere
      attn_mask = torch.arange(
          0, n_subtokens, device=self.device
      ).expand((n_words, n_subtokens))
      attn_mask = (attn_mask >= word_starts.unsqueeze(1)) * (
          attn_mask < word_ends.unsqueeze(1)
      )
      attn_mask = torch.log(attn_mask.to(torch.float))
  
      attn_scores = self.attn(bert_out).T  # [1, n_subtokens]
      attn_scores = attn_scores.expand((n_words, n_subtokens))
      attn_scores = attn_mask + attn_scores
      del attn_mask
      return torch.softmax(attn_scores, dim=1)
  
file_path: stanza/stanza/models/coref/word_encoder.py
imports: from typing import Tuple
  import torch
  from stanza.models.coref.config import Config
  from stanza.models.coref.const import Doc
label_desc: Use image node_id 4 for calling the WordEncoder obj's underlying member method code with example usage: obj._attn_scores(bert_out, word_starts, word_ends) and returns: torch