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 an embedding representation of pairs of spans for the pairwise scoring function
  to consider. This includes both the original span representations, the element-wise
  similarity of the span representations, and an embedding representation of the distance
  between the two spans.
  
  Parameters
  ----------
  top_span_embeddings : ``torch.FloatTensor``, required.
      Embedding representations of the top spans. Has shape
      (batch_size, num_spans_to_keep, embedding_size).
  antecedent_embeddings : ``torch.FloatTensor``, required.
      Embedding representations of the antecedent spans we are considering
      for each top span. Has shape
      (batch_size, num_spans_to_keep, max_antecedents, embedding_size).
  antecedent_offsets : ``torch.IntTensor``, required.
      The offsets between each top span and its antecedent spans in terms
      of spans we are considering. Has shape (1, max_antecedents).
  
  Returns
  -------
  span_pair_embeddings : ``torch.FloatTensor``
      Embedding representation of the pair of spans to consider. Has shape
      (batch_size, num_spans_to_keep, max_antecedents, embedding_size)
docstr_tok: ["Computes","an","embedding","representation","of","pairs","of","spans","for","the","pairwise","scoring","function","to","consider",".","This","includes","both","the","original","span","representations",",","the","element-wise","similarity","of","the","span","representations",",","and","an","embedding","representation","of","the","distance","between","the","two","spans",".","Parameters","--","--","--","--","--","top_span_embeddings",":","``","torch.FloatTensor","``",",","required",".","Embedding","representations","of","the","top","spans",".","Has","shape","(","batch_size",",","num_spans_to_keep",",","embedding_size",")",".","antecedent_embeddings",":","``","torch.FloatTensor","``",",","required",".","Embedding","representations","of","the","antecedent","spans","we","are","considering","for","each","top","span",".","Has","shape","(","batch_size",",","num_spans_to_keep",",","max_antecedents",",","embedding_size",")",".","antecedent_offsets",":","``","torch.IntTensor","``",",","required",".","The","offsets","between","each","top","span","and","its","antecedent","spans","in","terms","of","spans","we","are","considering",".","Has","shape","(","1",",","max_antecedents",")",".","Returns","--","--","--","-","span_pair_embeddings",":","``","torch.FloatTensor","``","Embedding","representation","of","the","pair","of","spans","to","consider",".","Has","shape","(","batch_size",",","num_spans_to_keep",",","max_antecedents",",","embedding_size",")"]
code: def _compute_span_pair_embeddings(
      self,
      top_span_embeddings,
      antecedent_embeddings,
      antecedent_offsets,
  ):
      """
      Computes an embedding representation of pairs of spans for the pairwise scoring function
      to consider. This includes both the original span representations, the element-wise
      similarity of the span representations, and an embedding representation of the distance
      between the two spans.
  
      Parameters
      ----------
      top_span_embeddings : ``torch.FloatTensor``, required.
          Embedding representations of the top spans. Has shape
          (batch_size, num_spans_to_keep, embedding_size).
      antecedent_embeddings : ``torch.FloatTensor``, required.
          Embedding representations of the antecedent spans we are considering
          for each top span. Has shape
          (batch_size, num_spans_to_keep, max_antecedents, embedding_size).
      antecedent_offsets : ``torch.IntTensor``, required.
          The offsets between each top span and its antecedent spans in terms
          of spans we are considering. Has shape (1, max_antecedents).
  
      Returns
      -------
      span_pair_embeddings : ``torch.FloatTensor``
          Embedding representation of the pair of spans to consider. Has shape
          (batch_size, num_spans_to_keep, max_antecedents, embedding_size)
      """
      # Shape: (batch_size, num_spans_to_keep, max_antecedents, embedding_size)
      target_embeddings = top_span_embeddings.unsqueeze(2).expand_as(
          antecedent_embeddings
      )
  
      # Shape: (1, max_antecedents, embedding_size)
      antecedent_distance_embeddings = self._distance_embedding(
          util.bucket_values(
              antecedent_offsets,
              num_total_buckets=self._num_distance_buckets,
          )
      )
  
      # Shape: (1, 1, max_antecedents, embedding_size)
      antecedent_distance_embeddings = (
          antecedent_distance_embeddings.unsqueeze(0)
      )
  
      expanded_distance_embeddings_shape = (
          antecedent_embeddings.size(0),
          antecedent_embeddings.size(1),
          antecedent_embeddings.size(2),
          antecedent_distance_embeddings.size(-1),
      )
      # Shape: (batch_size, num_spans_to_keep, max_antecedents, embedding_size)
      antecedent_distance_embeddings = (
          antecedent_distance_embeddings.expand(
              *expanded_distance_embeddings_shape
          )
      )
  
      # Shape: (batch_size, num_spans_to_keep, max_antecedents, embedding_size)
      span_pair_embeddings = torch.cat(
          [
              target_embeddings,
              antecedent_embeddings,
              antecedent_embeddings * target_embeddings,
              antecedent_distance_embeddings,
          ],
          -1,
      )
      return span_pair_embeddings
  
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 6 for calling the CoreferenceResolver obj's underlying member method code with example usage: obj._compute_span_pair_embeddings(top_span_embeddings, antecedent_embeddings, antecedent_offsets) and returns: span_pair_embeddings