class_docstr: APIs to help create and train an Average Word Embedding text classifier.
class_docstr_tok: ["APIs","to","help","create","and","train","an","Average","Word","Embedding","text","classifier","."]
code: def __init__(
      self,
      model_spec: ms.AverageWordEmbeddingClassifierSpec,
      model_options: mo.AverageWordEmbeddingModelOptions,
      hparams: hp.AverageWordEmbeddingHParams,
      label_names: Sequence[str],
  ):
      super().__init__(model_spec, label_names, hparams.shuffle)
      self._model_options = model_options
      self._hparams = hparams
      self._callbacks = model_util.get_default_callbacks(
          self._hparams.export_dir
      )
      self._loss_function = "sparse_categorical_crossentropy"
      self._metric_functions = [
          "accuracy",
          metrics.SparsePrecision(name="precision", dtype=tf.float32),
          metrics.SparseRecall(name="recall", dtype=tf.float32),
      ]
      self._text_preprocessor: (
          preprocessor.AverageWordEmbeddingClassifierPreprocessor
      ) = None
  
imports: import abc
  import os
  import tempfile
  from typing import Any, Optional, Sequence, Tuple
  import tensorflow
  from tensorflow_addons import optimizers
  import tensorflow_hub
  from mediapipe.model_maker.python.core.data import dataset
  from mediapipe.model_maker.python.core.tasks import classifier
  from mediapipe.model_maker.python.core.utils import hub_loader
  from mediapipe.model_maker.python.core.utils import loss_functions
  from mediapipe.model_maker.python.core.utils import metrics
  from mediapipe.model_maker.python.core.utils import model_util
  from mediapipe.model_maker.python.core.utils import quantization
  from mediapipe.model_maker.python.text.text_classifier import bert_tokenizer
  from mediapipe.model_maker.python.text.text_classifier import dataset
  from mediapipe.model_maker.python.text.text_classifier import hyperparameters
  from mediapipe.model_maker.python.text.text_classifier import model_options
  from mediapipe.model_maker.python.text.text_classifier import model_spec
  from mediapipe.model_maker.python.text.text_classifier import model_with_tokenizer
  from mediapipe.model_maker.python.text.text_classifier import preprocessor
  from mediapipe.model_maker.python.text.text_classifier import text_classifier_options
  from mediapipe.tasks.python.metadata.metadata_writers import metadata_writer
  from mediapipe.tasks.python.metadata.metadata_writers import text_classifier
label_desc: Use image node_id 1 to create a new _AverageWordEmbeddingClassifier object from inherited base classes: TextClassifier with example: obj = _AverageWordEmbeddingClassifier(model_spec, model_options, hparams, label_names)