class_docstr: This `Model` implements a basic text classifier. After embedding the text into
  a text field, we will optionally encode the embeddings with a `Seq2SeqEncoder`. The
  resulting sequence is pooled using a `Seq2VecEncoder` and then passed to
  a linear classification layer, which projects into the label space. If a
  `Seq2SeqEncoder` is not provided, we will pass the embedded text directly to the
  `Seq2VecEncoder`.
  
  Registered as a `Model` with name "basic_classifier".
  
  # Parameters
  
  vocab : `Vocabulary`
  text_field_embedder : `TextFieldEmbedder`
      Used to embed the input text into a `TextField`
  seq2seq_encoder : `Seq2SeqEncoder`, optional (default=`None`)
      Optional Seq2Seq encoder layer for the input text.
  seq2vec_encoder : `Seq2VecEncoder`
      Required Seq2Vec encoder layer. If `seq2seq_encoder` is provided, this encoder
      will pool its output. Otherwise, this encoder will operate directly on the output
      of the `text_field_embedder`.
  feedforward : `FeedForward`, optional, (default = `None`)
      An optional feedforward layer to apply after the seq2vec_encoder.
  dropout : `float`, optional (default = `None`)
      Dropout percentage to use.
  num_labels : `int`, optional (default = `None`)
      Number of labels to project to in classification layer. By default, the classification layer will
      project to the size of the vocabulary namespace corresponding to labels.
  namespace : `str`, optional (default = `"tokens"`)
      Vocabulary namespace corresponding to the input text. By default, we use the "tokens" namespace.
  label_namespace : `str`, optional (default = `"labels"`)
      Vocabulary namespace corresponding to labels. By default, we use the "labels" namespace.
  initializer : `InitializerApplicator`, optional (default=`InitializerApplicator()`)
      If provided, will be used to initialize the model parameters.
class_docstr_tok: ["This","`","Model","`","implements","a","basic","text","classifier",".","After","embedding","the","text","into","a","text","field",",","we","will","optionally","encode","the","embeddings","with","a","`","Seq2SeqEncoder","`",".","The","resulting","sequence","is","pooled","using","a","`","Seq2VecEncoder","`","and","then","passed","to","a","linear","classification","layer",",","which","projects","into","the","label","space",".","If","a","`","Seq2SeqEncoder","`","is","not","provided",",","we","will","pass","the","embedded","text","directly","to","the","`","Seq2VecEncoder","`",".","Registered","as","a","`","Model","`","with","name","``","basic_classifier","''",".","#","Parameters","vocab",":","`","Vocabulary","`","text_field_embedder",":","`","TextFieldEmbedder","`","Used","to","embed","the","input","text","into","a","`","TextField","`","seq2seq_encoder",":","`","Seq2SeqEncoder","`",",","optional","(","default=","`","None","`",")","Optional","Seq2Seq","encoder","layer","for","the","input","text",".","seq2vec_encoder",":","`","Seq2VecEncoder","`","Required","Seq2Vec","encoder","layer",".","If","`","seq2seq_encoder","`","is","provided",",","this","encoder","will","pool","its","output",".","Otherwise",",","this","encoder","will","operate","directly","on","the","output","of","the","`","text_field_embedder","`",".","feedforward",":","`","FeedForward","`",",","optional",",","(","default","=","`","None","`",")","An","optional","feedforward","layer","to","apply","after","the","seq2vec_encoder",".","dropout",":","`","float","`",",","optional","(","default","=","`","None","`",")","Dropout","percentage","to","use",".","num_labels",":","`","int","`",",","optional","(","default","=","`","None","`",")","Number","of","labels","to","project","to","in","classification","layer",".","By","default",",","the","classification","layer","will","project","to","the","size","of","the","vocabulary","namespace","corresponding","to","labels",".","namespace",":","`","str","`",",","optional","(","default","=","`","``","tokens","''","`",")","Vocabulary","namespace","corresponding","to","the","input","text",".","By","default",",","we","use","the","``","tokens","''","namespace",".","label_namespace",":","`","str","`",",","optional","(","default","=","`","``","labels","''","`",")","Vocabulary","namespace","corresponding","to","labels",".","By","default",",","we","use","the","``","labels","''","namespace",".","initializer",":","`","InitializerApplicator","`",",","optional","(","default=","`","InitializerApplicator","(",")","`",")","If","provided",",","will","be","used","to","initialize","the","model","parameters","."]
code: def get_metrics(self, reset: bool = False) -> Dict[str, float]:
      metrics = {"accuracy": self._accuracy.get_metric(reset)}
      return metrics
  
file_path: allennlp/allennlp/models/basic_classifier.py
imports: from typing import Dict, Optional
  import torch
  from allennlp.data import TextFieldTensors, Vocabulary
  from allennlp.data.fields import MetadataField
  from allennlp.models.model import Model
  from allennlp.modules import FeedForward, Seq2SeqEncoder, Seq2VecEncoder, TextFieldEmbedder
  from allennlp.nn import InitializerApplicator, util
  from allennlp.nn.util import get_text_field_mask
  from allennlp.training.metrics import CategoricalAccuracy
label_desc: Use image node_id 4 for calling the BasicClassifier obj's underlying member method code with example usage: obj.get_metrics(reset) and returns: metrics