class_docstr: This model performs semantic role labeling using BIO tags using Propbank semantic roles.
  Specifically, it is an implmentation of `Deep Semantic Role Labeling - What works
  and what's next <https://homes.cs.washington.edu/~luheng/files/acl2017_hllz.pdf>`_ .
  
  This implementation is effectively a series of stacked interleaved LSTMs with highway
  connections, applied to embedded sequences of words concatenated with a binary indicator
  containing whether or not a word is the verbal predicate to generate predictions for in
  the sentence. Additionally, during inference, Viterbi decoding is applied to constrain
  the predictions to contain valid BIO sequences.
  
  Parameters
  ----------
  vocab : ``Vocabulary``, required
      A Vocabulary, required in order to compute sizes for input/output projections.
  text_field_embedder : ``TextFieldEmbedder``, required
      Used to embed the ``tokens`` ``TextField`` we get as input to the model.
  encoder : ``Seq2SeqEncoder``
      The encoder (with its own internal stacking) that we will use in between embedding tokens
      and predicting output tags.
  binary_feature_dim : int, required.
      The dimensionality of the embedding of the binary verb predicate features.
  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.
  label_smoothing : ``float``, optional (default = 0.0)
      Whether or not to use label smoothing on the labels when computing cross entropy loss.
class_docstr_tok: ["This","model","performs","semantic","role","labeling","using","BIO","tags","using","Propbank","semantic","roles",".","Specifically",",","it","is","an","implmentation","of","`","Deep","Semantic","Role","Labeling","-","What","works","and","what","'s","next","<","https",":","\/\/homes.cs.washington.edu\/~luheng\/files\/acl2017_hllz.pdf",">","`","_",".","This","implementation","is","effectively","a","series","of","stacked","interleaved","LSTMs","with","highway","connections",",","applied","to","embedded","sequences","of","words","concatenated","with","a","binary","indicator","containing","whether","or","not","a","word","is","the","verbal","predicate","to","generate","predictions","for","in","the","sentence",".","Additionally",",","during","inference",",","Viterbi","decoding","is","applied","to","constrain","the","predictions","to","contain","valid","BIO","sequences",".","Parameters","--","--","--","--","--","vocab",":","``","Vocabulary","``",",","required","A","Vocabulary",",","required","in","order","to","compute","sizes","for","input\/output","projections",".","text_field_embedder",":","``","TextFieldEmbedder","``",",","required","Used","to","embed","the","``","tokens","``","``","TextField","``","we","get","as","input","to","the","model",".","encoder",":","``","Seq2SeqEncoder","``","The","encoder","(","with","its","own","internal","stacking",")","that","we","will","use","in","between","embedding","tokens","and","predicting","output","tags",".","binary_feature_dim",":","int",",","required",".","The","dimensionality","of","the","embedding","of","the","binary","verb","predicate","features",".","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",".","label_smoothing",":","``","float","``",",","optional","(","default","=","0.0",")","Whether","or","not","to","use","label","smoothing","on","the","labels","when","computing","cross","entropy","loss","."]
code: def __init__(
      self,
      vocab,
      text_field_embedder,
      encoder,
      binary_feature_dim,
      embedding_dropout=0.0,
      initializer=InitializerApplicator(),
      regularizer=None,
      label_smoothing=None,
  ):
      super(SemanticRoleLabeler, self).__init__(vocab, regularizer)
  
      self.text_field_embedder = text_field_embedder
      self.num_classes = self.vocab.get_vocab_size("labels")
  
      # For the span based evaluation, we don't want to consider labels
      # for verb, because the verb index is provided to the model.
      self.span_metric = SpanBasedF1Measure(
          vocab, tag_namespace="labels", ignore_classes=["V"]
      )
  
      self.encoder = encoder
      # There are exactly 2 binary features for the verb predicate embedding.
      self.binary_feature_embedding = Embedding(2, binary_feature_dim)
      self.tag_projection_layer = TimeDistributed(
          Linear(self.encoder.get_output_dim(), self.num_classes)
      )
      self.embedding_dropout = Dropout(p=embedding_dropout)
      self._label_smoothing = label_smoothing
  
      check_dimensions_match(
          text_field_embedder.get_output_dim() + binary_feature_dim,
          encoder.get_input_dim(),
          "text embedding dim + verb indicator embedding dim",
          "encoder input dim",
      )
      initializer(self)
  
imports: from __future__ import absolute_import
  import torch
  from torch.nn.modules import Linear, Dropout
  import torch.nn.functional
  from allennlp.common.checks import check_dimensions_match
  from allennlp.data import Vocabulary
  from allennlp.modules import Seq2SeqEncoder, TimeDistributed, TextFieldEmbedder
  from allennlp.modules.token_embedders import Embedding
  from allennlp.models.model import Model
  from allennlp.nn import InitializerApplicator, RegularizerApplicator
  from allennlp.nn.util import get_text_field_mask, sequence_cross_entropy_with_logits
  from allennlp.nn.util import get_lengths_from_binary_sequence_mask, viterbi_decode
  from allennlp.training.metrics import SpanBasedF1Measure
label_desc: Use image node_id 1 to create a new SemanticRoleLabeler object from inherited base classes: Model with example: obj = SemanticRoleLabeler(vocab, text_field_embedder, encoder, binary_feature_dim, embedding_dropout, initializer, regularizer, label_smoothing)