class_docstr: An ``IntraSentenceAttentionEncoder`` is a :class:`Seq2SeqEncoder` that merges the original word
  representations with an attention (for each word) over other words in the sentence.  As a
  :class:`Seq2SeqEncoder`, the input to this module is of shape ``(batch_size, num_tokens,
  input_dim)``, and the output is of shape ``(batch_size, num_tokens, output_dim)``.
  
  We compute the attention using a configurable :class:`SimilarityFunction`, which could have
  multiple attention heads.  The operation for merging the original representations with the
  attended representations is also configurable (e.g., you can concatenate them, add them,
  multiply them, etc.).
  
  Parameters
  ----------
  input_dim : ``int``
      The dimension of the vector for each element in the input sequence;
      ``input_tensor.size(-1)``.
  projection_dim : ``int``, optional
      If given, we will do a linear projection of the input sequence to this dimension before
      performing the attention-weighted sum.
  similarity_function : ``SimilarityFunction``, optional
      The similarity function to use when computing attentions.  Default is to use a dot product.
  num_attention_heads: ``int``, optional
      If this is greater than one (default is 1), we will split the input into several "heads" to
      compute multi-headed weighted sums.  Must be used with a multi-headed similarity function,
      and you almost certainly want to do a projection in conjunction with the multiple heads.
  combination : ``str``, optional
      This string defines how we merge the original word representations with the result of the
      intra-sentence attention.  This will be passed to
      :func:`~allennlp.nn.util.combine_tensors`; see that function for more detail on exactly how
      this works, but some simple examples are ``"1,2"`` for concatenation (the default),
      ``"1+2"`` for adding the two, or ``"2"`` for only keeping the attention representation.
  output_dim : ``bool``, optional (default = None)
      The dimension of an optional output projection.
class_docstr_tok: ["An","``","IntraSentenceAttentionEncoder","``","is","a",":","class",":","`","Seq2SeqEncoder","`","that","merges","the","original","word","representations","with","an","attention","(","for","each","word",")","over","other","words","in","the","sentence",".","As","a",":","class",":","`","Seq2SeqEncoder","`",",","the","input","to","this","module","is","of","shape","``","(","batch_size",",","num_tokens",",","input_dim",")","``",",","and","the","output","is","of","shape","``","(","batch_size",",","num_tokens",",","output_dim",")","``",".","We","compute","the","attention","using","a","configurable",":","class",":","`","SimilarityFunction","`",",","which","could","have","multiple","attention","heads",".","The","operation","for","merging","the","original","representations","with","the","attended","representations","is","also","configurable","(","e.g.",",","you","can","concatenate","them",",","add","them",",","multiply","them",",","etc.",")",".","Parameters","--","--","--","--","--","input_dim",":","``","int","``","The","dimension","of","the","vector","for","each","element","in","the","input","sequence",";","``","input_tensor.size","(","-1",")","``",".","projection_dim",":","``","int","``",",","optional","If","given",",","we","will","do","a","linear","projection","of","the","input","sequence","to","this","dimension","before","performing","the","attention-weighted","sum",".","similarity_function",":","``","SimilarityFunction","``",",","optional","The","similarity","function","to","use","when","computing","attentions",".","Default","is","to","use","a","dot","product",".","num_attention_heads",":","``","int","``",",","optional","If","this","is","greater","than","one","(","default","is","1",")",",","we","will","split","the","input","into","several","``","heads","''","to","compute","multi-headed","weighted","sums",".","Must","be","used","with","a","multi-headed","similarity","function",",","and","you","almost","certainly","want","to","do","a","projection","in","conjunction","with","the","multiple","heads",".","combination",":","``","str","``",",","optional","This","string","defines","how","we","merge","the","original","word","representations","with","the","result","of","the","intra-sentence","attention",".","This","will","be","passed","to",":","func",":","`","~allennlp.nn.util.combine_tensors","`",";","see","that","function","for","more","detail","on","exactly","how","this","works",",","but","some","simple","examples","are","``","``","1,2","''","``","for","concatenation","(","the","default",")",",","``","``","1+2","''","``","for","adding","the","two",",","or","``","``","2","''","``","for","only","keeping","the","attention","representation",".","output_dim",":","``","bool","``",",","optional","(","default","=","None",")","The","dimension","of","an","optional","output","projection","."]
code: def get_input_dim(self):
      return self._input_dim
  
file_path: magnitude/pymagnitude/third_party/allennlp/modules/seq2seq_encoders/intra_sentence_attention.py
imports: from __future__ import absolute_import
  import torch
  from torch.nn import Linear
  from allennlp.common.checks import ConfigurationError
  from allennlp.modules.matrix_attention.legacy_matrix_attention import LegacyMatrixAttention
  from allennlp.modules.seq2seq_encoders.seq2seq_encoder import Seq2SeqEncoder
  from allennlp.modules.similarity_functions import DotProductSimilarity, SimilarityFunction
  from allennlp.modules.similarity_functions import MultiHeadedSimilarity
  from allennlp.nn import util
label_desc: Use image node_id 2 for calling the IntraSentenceAttentionEncoder obj's underlying member method code with example usage: obj.get_input_dim() and returns: self