class_docstr: This ``Model`` implements the coreference resolution model described "End-to-end Neural
  Coreference Resolution"
  <https://www.semanticscholar.org/paper/End-to-end-Neural-Coreference-Resolution-Lee-He/3f2114893dc44eacac951f148fbff142ca200e83>
  by Lee et al., 2017.
  The basic outline of this model is to get an embedded representation of each span in the
  document. These span representations are scored and used to prune away spans that are unlikely
  to occur in a coreference cluster. For the remaining spans, the model decides which antecedent
  span (if any) they are coreferent with. The resulting coreference links, after applying
  transitivity, imply a clustering of the spans in the document.
  
  Parameters
  ----------
  vocab : ``Vocabulary``
  text_field_embedder : ``TextFieldEmbedder``
      Used to embed the ``text`` ``TextField`` we get as input to the model.
  context_layer : ``Seq2SeqEncoder``
      This layer incorporates contextual information for each word in the document.
  mention_feedforward : ``FeedForward``
      This feedforward network is applied to the span representations which is then scored
      by a linear layer.
  antecedent_feedforward: ``FeedForward``
      This feedforward network is applied to pairs of span representation, along with any
      pairwise features, which is then scored by a linear layer.
  feature_size: ``int``
      The embedding size for all the embedded features, such as distances or span widths.
  max_span_width: ``int``
      The maximum width of candidate spans.
  spans_per_word: float, required.
      A multiplier between zero and one which controls what percentage of candidate mention
      spans we retain with respect to the number of words in the document.
  max_antecedents: int, required.
      For each mention which survives the pruning stage, we consider this many antecedents.
  lexical_dropout: ``int``
      The probability of dropping out dimensions of the embedded text.
  initializer : ``InitializerApplicator``, optional (default=``InitializerApplicator()``)
      Used to initialize the model parameters.
  regularizer : ``RegularizerApplicator``, optional (default=``None``)
      If provided, will be used to calculate the regularization penalty during training.
docstr: Computes scores for every pair of spans. Additionally, a dummy label is included,
  representing the decision that the span is not coreferent with anything. For the dummy
  label, the score is always zero. For the true antecedent spans, the score consists of
  the pairwise antecedent score and the unary mention scores for the span and its
  antecedent. The factoring allows the model to blame many of the absent links on bad
  spans, enabling the pruning strategy used in the forward pass.
  
  Parameters
  ----------
  pairwise_embeddings: ``torch.FloatTensor``, required.
      Embedding representations of pairs of spans. Has shape
      (batch_size, num_spans_to_keep, max_antecedents, encoding_dim)
  top_span_mention_scores: ``torch.FloatTensor``, required.
      Mention scores for every span. Has shape
      (batch_size, num_spans_to_keep, max_antecedents).
  antecedent_mention_scores: ``torch.FloatTensor``, required.
      Mention scores for every antecedent. Has shape
      (batch_size, num_spans_to_keep, max_antecedents).
  antecedent_log_mask: ``torch.FloatTensor``, required.
      The log of the mask for valid antecedents.
  
  Returns
  -------
  coreference_scores: ``torch.FloatTensor``
      A tensor of shape (batch_size, num_spans_to_keep, max_antecedents + 1),
      representing the unormalised score for each (span, antecedent) pair
      we considered.
docstr_tok: ["Computes","scores","for","every","pair","of","spans",".","Additionally",",","a","dummy","label","is","included",",","representing","the","decision","that","the","span","is","not","coreferent","with","anything",".","For","the","dummy","label",",","the","score","is","always","zero",".","For","the","true","antecedent","spans",",","the","score","consists","of","the","pairwise","antecedent","score","and","the","unary","mention","scores","for","the","span","and","its","antecedent",".","The","factoring","allows","the","model","to","blame","many","of","the","absent","links","on","bad","spans",",","enabling","the","pruning","strategy","used","in","the","forward","pass",".","Parameters","--","--","--","--","--","pairwise_embeddings",":","``","torch.FloatTensor","``",",","required",".","Embedding","representations","of","pairs","of","spans",".","Has","shape","(","batch_size",",","num_spans_to_keep",",","max_antecedents",",","encoding_dim",")","top_span_mention_scores",":","``","torch.FloatTensor","``",",","required",".","Mention","scores","for","every","span",".","Has","shape","(","batch_size",",","num_spans_to_keep",",","max_antecedents",")",".","antecedent_mention_scores",":","``","torch.FloatTensor","``",",","required",".","Mention","scores","for","every","antecedent",".","Has","shape","(","batch_size",",","num_spans_to_keep",",","max_antecedents",")",".","antecedent_log_mask",":","``","torch.FloatTensor","``",",","required",".","The","log","of","the","mask","for","valid","antecedents",".","Returns","--","--","--","-","coreference_scores",":","``","torch.FloatTensor","``","A","tensor","of","shape","(","batch_size",",","num_spans_to_keep",",","max_antecedents","+","1",")",",","representing","the","unormalised","score","for","each","(","span",",","antecedent",")","pair","we","considered","."]
code: def _compute_coreference_scores(
      self,
      pairwise_embeddings,
      top_span_mention_scores,
      antecedent_mention_scores,
      antecedent_log_mask,
  ):
      """
      Computes scores for every pair of spans. Additionally, a dummy label is included,
      representing the decision that the span is not coreferent with anything. For the dummy
      label, the score is always zero. For the true antecedent spans, the score consists of
      the pairwise antecedent score and the unary mention scores for the span and its
      antecedent. The factoring allows the model to blame many of the absent links on bad
      spans, enabling the pruning strategy used in the forward pass.
  
      Parameters
      ----------
      pairwise_embeddings: ``torch.FloatTensor``, required.
          Embedding representations of pairs of spans. Has shape
          (batch_size, num_spans_to_keep, max_antecedents, encoding_dim)
      top_span_mention_scores: ``torch.FloatTensor``, required.
          Mention scores for every span. Has shape
          (batch_size, num_spans_to_keep, max_antecedents).
      antecedent_mention_scores: ``torch.FloatTensor``, required.
          Mention scores for every antecedent. Has shape
          (batch_size, num_spans_to_keep, max_antecedents).
      antecedent_log_mask: ``torch.FloatTensor``, required.
          The log of the mask for valid antecedents.
  
      Returns
      -------
      coreference_scores: ``torch.FloatTensor``
          A tensor of shape (batch_size, num_spans_to_keep, max_antecedents + 1),
          representing the unormalised score for each (span, antecedent) pair
          we considered.
  
      """
      # Shape: (batch_size, num_spans_to_keep, max_antecedents)
      antecedent_scores = self._antecedent_scorer(
          self._antecedent_feedforward(pairwise_embeddings)
      ).squeeze(-1)
      antecedent_scores += (
          top_span_mention_scores + antecedent_mention_scores
      )
      antecedent_scores += antecedent_log_mask
  
      # Shape: (batch_size, num_spans_to_keep, 1)
      shape = [antecedent_scores.size(0), antecedent_scores.size(1), 1]
      dummy_scores = antecedent_scores.new_zeros(*shape)
  
      # Shape: (batch_size, num_spans_to_keep, max_antecedents + 1)
      coreference_scores = torch.cat(
          [dummy_scores, antecedent_scores], -1
      )
      return coreference_scores
  
imports: from __future__ import absolute_import
  import logging
  import math
  import torch
  import torch.nn.functional
  from allennlp.data import Vocabulary
  from allennlp.models.model import Model
  from allennlp.modules.token_embedders import Embedding
  from allennlp.modules import FeedForward
  from allennlp.modules import Seq2SeqEncoder, TimeDistributed, TextFieldEmbedder, SpanPruner
  from allennlp.modules.span_extractors import SelfAttentiveSpanExtractor, EndpointSpanExtractor
  from allennlp.nn import util, InitializerApplicator, RegularizerApplicator
  from allennlp.training.metrics import MentionRecall, ConllCorefScores
label_desc: Use image node_id 8 for calling the CoreferenceResolver obj's underlying member method code with example usage: obj._compute_coreference_scores(pairwise_embeddings, top_span_mention_scores, antecedent_mention_scores, antecedent_log_mask) and returns: coreference_scores