class_docstr: Calculates anaphoricity scores by passing the inputs into a FFNN 
docstr: Builds the matrix used as input for AnaphoricityScorer.
  
  Args:
      all_mentions (torch.Tensor): [n_mentions, mention_emb],
          all the valid mentions of the document,
          can be on a different device
      mentions_batch (torch.Tensor): [batch_size, mention_emb],
          the mentions of the current batch,
          is expected to be on the current device
      pw_batch (torch.Tensor): [batch_size, n_ants, pw_emb],
          pairwise features of the current batch,
          is expected to be on the current device
      top_indices_batch (torch.Tensor): [batch_size, n_ants],
          indices of antecedents of each mention
  
  Returns:
      torch.Tensor: [batch_size, n_ants, pair_emb]
docstr_tok: ["Builds","the","matrix","used","as","input","for","AnaphoricityScorer",".","Args",":","all_mentions","(","torch.Tensor",")",":","[","n_mentions",",","mention_emb","]",",","all","the","valid","mentions","of","the","document",",","can","be","on","a","different","device","mentions_batch","(","torch.Tensor",")",":","[","batch_size",",","mention_emb","]",",","the","mentions","of","the","current","batch",",","is","expected","to","be","on","the","current","device","pw_batch","(","torch.Tensor",")",":","[","batch_size",",","n_ants",",","pw_emb","]",",","pairwise","features","of","the","current","batch",",","is","expected","to","be","on","the","current","device","top_indices_batch","(","torch.Tensor",")",":","[","batch_size",",","n_ants","]",",","indices","of","antecedents","of","each","mention","Returns",":","torch.Tensor",":","[","batch_size",",","n_ants",",","pair_emb","]"]
code: def _get_pair_matrix(
      all_mentions: torch.Tensor,
      mentions_batch: torch.Tensor,
      pw_batch: torch.Tensor,
      top_indices_batch: torch.Tensor,
  ) -> torch.Tensor:
      """
      Builds the matrix used as input for AnaphoricityScorer.
  
      Args:
          all_mentions (torch.Tensor): [n_mentions, mention_emb],
              all the valid mentions of the document,
              can be on a different device
          mentions_batch (torch.Tensor): [batch_size, mention_emb],
              the mentions of the current batch,
              is expected to be on the current device
          pw_batch (torch.Tensor): [batch_size, n_ants, pw_emb],
              pairwise features of the current batch,
              is expected to be on the current device
          top_indices_batch (torch.Tensor): [batch_size, n_ants],
              indices of antecedents of each mention
  
      Returns:
          torch.Tensor: [batch_size, n_ants, pair_emb]
      """
      emb_size = mentions_batch.shape[1]
      n_ants = pw_batch.shape[1]
  
      a_mentions = mentions_batch.unsqueeze(1).expand(
          -1, n_ants, emb_size
      )
      b_mentions = all_mentions[top_indices_batch]
      similarity = a_mentions * b_mentions
  
      out = torch.cat(
          (a_mentions, b_mentions, similarity, pw_batch), dim=2
      )
      return out
  
file_path: stanza/stanza/models/coref/anaphoricity_scorer.py
imports: import torch
  from stanza.models.coref import utils
  from stanza.models.coref.config import Config
label_desc: Use image node_id 4 for calling the AnaphoricityScorer obj's underlying member method code with example usage: obj._get_pair_matrix(all_mentions, mentions_batch, pw_batch, top_indices_batch) and returns: out