class_docstr: APIs to help create and train a BERT-based text classifier.
class_docstr_tok: ["APIs","to","help","create","and","train","a","BERT-based","text","classifier","."]
docstr: Creates a BERT-based classifier model.
  
  The model architecture consists of stacking a dense classification layer and
  dropout layer on top of the BERT encoder outputs.
code: def _create_model(self):
      """Creates a BERT-based classifier model.
  
      The model architecture consists of stacking a dense classification layer and
      dropout layer on top of the BERT encoder outputs.
      """
      encoder_inputs = dict(
          input_word_ids=tf.keras.layers.Input(
              shape=(self._model_options.seq_len,),
              dtype=tf.int32,
              name="input_word_ids",
          ),
          input_mask=tf.keras.layers.Input(
              shape=(self._model_options.seq_len,),
              dtype=tf.int32,
              name="input_mask",
          ),
          input_type_ids=tf.keras.layers.Input(
              shape=(self._model_options.seq_len,),
              dtype=tf.int32,
              name="input_type_ids",
          ),
      )
      if self._model_spec.is_tf2:
          encoder = hub.KerasLayer(
              self._model_spec.get_path(),
              trainable=self._model_options.do_fine_tuning,
              load_options=tf.saved_model.LoadOptions(
                  experimental_io_device="/job:localhost"
              ),
          )
          encoder_outputs = encoder(encoder_inputs)
          pooled_output = encoder_outputs["pooled_output"]
      else:
          renamed_inputs = dict(
              input_ids=encoder_inputs["input_word_ids"],
              input_mask=encoder_inputs["input_mask"],
              segment_ids=encoder_inputs["input_type_ids"],
          )
          encoder = hub_loader.HubKerasLayerV1V2(
              self._model_spec.get_path(),
              signature="tokens",
              output_key="pooled_output",
              trainable=self._model_options.do_fine_tuning,
          )
          pooled_output = encoder(renamed_inputs)
  
      output = tf.keras.layers.Dropout(
          rate=self._model_options.dropout_rate
      )(pooled_output)
      initializer = tf.keras.initializers.TruncatedNormal(
          stddev=self._INITIALIZER_RANGE
      )
      output = tf.keras.layers.Dense(
          self._num_classes,
          kernel_initializer=initializer,
          name="output",
          activation="softmax",
          dtype=tf.float32,
      )(output)
      self._model = tf.keras.Model(
          inputs=encoder_inputs, outputs=output
      )
  
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 6 for calling the _BertClassifier obj's underlying member method code with example usage: obj._create_model() without return types