class_docstr: This ``Model`` implements the Decomposable Attention model described in `"A Decomposable
  Attention Model for Natural Language Inference"
  <https://www.semanticscholar.org/paper/A-Decomposable-Attention-Model-for-Natural-Languag-Parikh-T%C3%A4ckstr%C3%B6m/07a9478e87a8304fc3267fa16e83e9f3bbd98b27>`_
  by Parikh et al., 2016, with some optional enhancements before the decomposable attention
  actually happens.  Parikh's original model allowed for computing an "intra-sentence" attention
  before doing the decomposable entailment step.  We generalize this to any
  :class:`Seq2SeqEncoder` that can be applied to the premise and/or the hypothesis before
  computing entailment.
  
  The basic outline of this model is to get an embedded representation of each word in the
  premise and hypothesis, align words between the two, compare the aligned phrases, and make a
  final entailment decision based on this aggregated comparison.  Each step in this process uses
  a feedforward network to modify the representation.
  
  Parameters
  ----------
  vocab : ``Vocabulary``
  text_field_embedder : ``TextFieldEmbedder``
      Used to embed the ``premise`` and ``hypothesis`` ``TextFields`` we get as input to the
      model.
  attend_feedforward : ``FeedForward``
      This feedforward network is applied to the encoded sentence representations before the
      similarity matrix is computed between words in the premise and words in the hypothesis.
  similarity_function : ``SimilarityFunction``
      This is the similarity function used when computing the similarity matrix between words in
      the premise and words in the hypothesis.
  compare_feedforward : ``FeedForward``
      This feedforward network is applied to the aligned premise and hypothesis representations,
      individually.
  aggregate_feedforward : ``FeedForward``
      This final feedforward network is applied to the concatenated, summed result of the
      ``compare_feedforward`` network, and its output is used as the entailment class logits.
  premise_encoder : ``Seq2SeqEncoder``, optional (default=``None``)
      After embedding the premise, we can optionally apply an encoder.  If this is ``None``, we
      will do nothing.
  hypothesis_encoder : ``Seq2SeqEncoder``, optional (default=``None``)
      After embedding the hypothesis, we can optionally apply an encoder.  If this is ``None``,
      we will use the ``premise_encoder`` for the encoding (doing nothing if ``premise_encoder``
      is also ``None``).
  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.
class_docstr_tok: ["This","``","Model","``","implements","the","Decomposable","Attention","model","described","in","`","``","A","Decomposable","Attention","Model","for","Natural","Language","Inference","''","<","https",":","\/\/www.semanticscholar.org\/paper\/A-Decomposable-Attention-Model-for-Natural-Languag-Parikh-T","%","C3","%","A4ckstr","%","C3","%","B6m\/07a9478e87a8304fc3267fa16e83e9f3bbd98b27",">","`","_","by","Parikh","et","al.",",","2016",",","with","some","optional","enhancements","before","the","decomposable","attention","actually","happens",".","Parikh","'s","original","model","allowed","for","computing","an","``","intra-sentence","''","attention","before","doing","the","decomposable","entailment","step",".","We","generalize","this","to","any",":","class",":","`","Seq2SeqEncoder","`","that","can","be","applied","to","the","premise","and\/or","the","hypothesis","before","computing","entailment",".","The","basic","outline","of","this","model","is","to","get","an","embedded","representation","of","each","word","in","the","premise","and","hypothesis",",","align","words","between","the","two",",","compare","the","aligned","phrases",",","and","make","a","final","entailment","decision","based","on","this","aggregated","comparison",".","Each","step","in","this","process","uses","a","feedforward","network","to","modify","the","representation",".","Parameters","--","--","--","--","--","vocab",":","``","Vocabulary","``","text_field_embedder",":","``","TextFieldEmbedder","``","Used","to","embed","the","``","premise","``","and","``","hypothesis","``","``","TextFields","``","we","get","as","input","to","the","model",".","attend_feedforward",":","``","FeedForward","``","This","feedforward","network","is","applied","to","the","encoded","sentence","representations","before","the","similarity","matrix","is","computed","between","words","in","the","premise","and","words","in","the","hypothesis",".","similarity_function",":","``","SimilarityFunction","``","This","is","the","similarity","function","used","when","computing","the","similarity","matrix","between","words","in","the","premise","and","words","in","the","hypothesis",".","compare_feedforward",":","``","FeedForward","``","This","feedforward","network","is","applied","to","the","aligned","premise","and","hypothesis","representations",",","individually",".","aggregate_feedforward",":","``","FeedForward","``","This","final","feedforward","network","is","applied","to","the","concatenated",",","summed","result","of","the","``","compare_feedforward","``","network",",","and","its","output","is","used","as","the","entailment","class","logits",".","premise_encoder",":","``","Seq2SeqEncoder","``",",","optional","(","default=","``","None","``",")","After","embedding","the","premise",",","we","can","optionally","apply","an","encoder",".","If","this","is","``","None","``",",","we","will","do","nothing",".","hypothesis_encoder",":","``","Seq2SeqEncoder","``",",","optional","(","default=","``","None","``",")","After","embedding","the","hypothesis",",","we","can","optionally","apply","an","encoder",".","If","this","is","``","None","``",",","we","will","use","the","``","premise_encoder","``","for","the","encoding","(","doing","nothing","if","``","premise_encoder","``","is","also","``","None","``",")",".","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","."]
code: def get_metrics(self, reset=False):
      return {
          "accuracy": self._accuracy.get_metric(reset),
      }
  
file_path: magnitude/pymagnitude/third_party/allennlp/models/decomposable_attention.py
imports: from __future__ import absolute_import
  import torch
  from allennlp.common.checks import check_dimensions_match
  from allennlp.data import Vocabulary
  from allennlp.models.model import Model
  from allennlp.modules import FeedForward
  from allennlp.modules import Seq2SeqEncoder, SimilarityFunction, TimeDistributed, TextFieldEmbedder
  from allennlp.modules.matrix_attention.legacy_matrix_attention import LegacyMatrixAttention
  from allennlp.nn import InitializerApplicator, RegularizerApplicator
  from allennlp.nn.util import get_text_field_mask, last_dim_softmax, weighted_sum
  from allennlp.training.metrics import CategoricalAccuracy
label_desc: Use image node_id 3 for calling the DecomposableAttention obj's underlying member method code with example usage: obj.get_metrics(reset) and returns: dict