class_docstr: This ``SimpleTagger`` simply encodes a sequence of text with a stacked ``Seq2SeqEncoder``, then
  predicts a tag for each token in the sequence.
  
  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.
  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","``","SimpleTagger","``","simply","encodes","a","sequence","of","text","with","a","stacked","``","Seq2SeqEncoder","``",",","then","predicts","a","tag","for","each","token","in","the","sequence",".","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",".","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: Does a simple position-wise argmax over each token, converts indices to string labels, and
  adds a ``"tags"`` key to the dictionary with the result.
docstr_tok: ["Does","a","simple","position-wise","argmax","over","each","token",",","converts","indices","to","string","labels",",","and","adds","a","``","``","tags","''","``","key","to","the","dictionary","with","the","result","."]
code: def decode(self, output_dict):
      """
      Does a simple position-wise argmax over each token, converts indices to string labels, and
      adds a ``"tags"`` key to the dictionary with the result.
      """
      all_predictions = output_dict["class_probabilities"]
      all_predictions = all_predictions.cpu().data.numpy()
      if all_predictions.ndim == 3:
          predictions_list = [
              all_predictions[i]
              for i in range(all_predictions.shape[0])
          ]
      else:
          predictions_list = [all_predictions]
      all_tags = []
      for predictions in predictions_list:
          argmax_indices = numpy.argmax(predictions, axis=-1)
          tags = [
              self.vocab.get_token_from_index(x, namespace="labels")
              for x in argmax_indices
          ]
          all_tags.append(tags)
      output_dict["tags"] = all_tags
      return output_dict
  
file_path: magnitude/pymagnitude/third_party/allennlp/models/simple_tagger.py
imports: from __future__ import absolute_import
  import numpy
  import torch
  from torch.nn.modules.linear import Linear
  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.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.training.metrics import CategoricalAccuracy
label_desc: Use image node_id 3 for calling the SimpleTagger obj's underlying member method code with example usage: obj.decode(output_dict) and returns: output_dict