class_docstr: API for creating and training a text classification model.
class_docstr_tok: ["API","for","creating","and","training","a","text","classification","model","."]
docstr: Factory function that creates and trains a text classifier.
  
  Note that `train_data` and `validation_data` are expected to share the same
  `label_names` since they should be split from the same dataset.
  
  Args:
    train_data: Training data.
    validation_data: Validation data.
    options: Options for creating and training the text classifier.
  
  Returns:
    A text classifier.
  
  Raises:
    ValueError if `train_data` and `validation_data` do not have the
    same label_names or `options` contains an unknown `supported_model`
code: def create(
      cls,
      train_data: text_ds.Dataset,
      validation_data: text_ds.Dataset,
      options: text_classifier_options.TextClassifierOptions,
  ) -> "TextClassifier":
      """Factory function that creates and trains a text classifier.
  
      Note that `train_data` and `validation_data` are expected to share the same
      `label_names` since they should be split from the same dataset.
  
      Args:
        train_data: Training data.
        validation_data: Validation data.
        options: Options for creating and training the text classifier.
  
      Returns:
        A text classifier.
  
      Raises:
        ValueError if `train_data` and `validation_data` do not have the
        same label_names or `options` contains an unknown `supported_model`
      """
      if train_data.label_names != validation_data.label_names:
          raise ValueError(
              f"Training data label names {train_data.label_names} not equal to "
              f"validation data label names {validation_data.label_names}"
          )
  
      _validate(options)
      if options.model_options is None:
          options.model_options = (
              options.supported_model.value().model_options
          )
  
      if options.hparams is None:
          options.hparams = options.supported_model.value().hparams
  
      if isinstance(
          options.supported_model.value(), ms.BertClassifierSpec
      ):
          text_classifier = _BertClassifier.create_bert_classifier(
              train_data, validation_data, options
          )
      elif isinstance(
          options.supported_model.value(),
          ms.AverageWordEmbeddingClassifierSpec,
      ):
          text_classifier = _AverageWordEmbeddingClassifier.create_average_word_embedding_classifier(
              train_data, validation_data, options
          )
      else:
          raise ValueError(f"Unknown model {options.supported_model}")
  
      return text_classifier
  
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 2 for calling the TextClassifier obj's underlying member method code with example usage: obj.create(cls, train_data, validation_data, options) and returns: text_classifier