class_docstr: This `SimpleTagger` simply encodes a sequence of text with a stacked `Seq2SeqEncoder`, then
  predicts a tag for each token in the sequence.
  
  Registered as a `Model` with name "simple_tagger".
  
  # 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.
  calculate_span_f1 : `bool`, optional (default=`None`)
      Calculate span-level F1 metrics during training. If this is `True`, then
      `label_encoding` is required. If `None` and
      label_encoding is specified, this is set to `True`.
      If `None` and label_encoding is not specified, it defaults
      to `False`.
  label_encoding : `str`, optional (default=`None`)
      Label encoding to use when calculating span f1.
      Valid options are "BIO", "BIOUL", "IOB1", "BMES".
      Required if `calculate_span_f1` is true.
  label_namespace : `str`, optional (default=`labels`)
      This is needed to compute the SpanBasedF1Measure metric, if desired.
      Unless you did something unusual, the default value should be what you want.
  verbose_metrics : `bool`, optional (default = `False`)
      If true, metrics will be returned per label class in addition
      to the overall statistics.
  initializer : `InitializerApplicator`, optional (default=`InitializerApplicator()`)
      Used to initialize the model parameters.
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",".","Registered","as","a","`","Model","`","with","name","``","simple_tagger","''",".","#","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",".","calculate_span_f1",":","`","bool","`",",","optional","(","default=","`","None","`",")","Calculate","span-level","F1","metrics","during","training",".","If","this","is","`","True","`",",","then","`","label_encoding","`","is","required",".","If","`","None","`","and","label_encoding","is","specified",",","this","is","set","to","`","True","`",".","If","`","None","`","and","label_encoding","is","not","specified",",","it","defaults","to","`","False","`",".","label_encoding",":","`","str","`",",","optional","(","default=","`","None","`",")","Label","encoding","to","use","when","calculating","span","f1",".","Valid","options","are","``","BIO","''",",","``","BIOUL","''",",","``","IOB1","''",",","``","BMES","''",".","Required","if","`","calculate_span_f1","`","is","true",".","label_namespace",":","`","str","`",",","optional","(","default=","`","labels","`",")","This","is","needed","to","compute","the","SpanBasedF1Measure","metric",",","if","desired",".","Unless","you","did","something","unusual",",","the","default","value","should","be","what","you","want",".","verbose_metrics",":","`","bool","`",",","optional","(","default","=","`","False","`",")","If","true",",","metrics","will","be","returned","per","label","class","in","addition","to","the","overall","statistics",".","initializer",":","`","InitializerApplicator","`",",","optional","(","default=","`","InitializerApplicator","(",")","`",")","Used","to","initialize","the","model","parameters","."]
code: def get_metrics(self, reset: bool = False) -> Dict[str, float]:
      metrics_to_return = {
          metric_name: metric.get_metric(reset)
          for metric_name, metric in self.metrics.items()
      }
  
      if self.calculate_span_f1:
          f1_dict = self._f1_metric.get_metric(reset)  # type: ignore
          if self._verbose_metrics:
              metrics_to_return.update(f1_dict)
          else:
              metrics_to_return.update(
                  {x: y for x, y in f1_dict.items() if "overall" in x}
              )
      return metrics_to_return
  
file_path: allennlp/allennlp/models/simple_tagger.py
imports: from typing import Dict, Optional, List, Any
  import numpy
  import torch
  from torch.nn.modules.linear import Linear
  import torch.nn.functional
  from allennlp.common.checks import check_dimensions_match, ConfigurationError
  from allennlp.data import TextFieldTensors, Vocabulary
  from allennlp.modules import Seq2SeqEncoder, TimeDistributed, TextFieldEmbedder
  from allennlp.models.model import Model
  from allennlp.nn import InitializerApplicator
  from allennlp.nn.util import get_text_field_mask, sequence_cross_entropy_with_logits
  from allennlp.training.metrics import CategoricalAccuracy, SpanBasedF1Measure
label_desc: Use image node_id 4 for calling the SimpleTagger obj's underlying member method code with example usage: obj.get_metrics(reset) and returns: metrics_to_return