docstr: Checks TFLite conversion and inference.
docstr_tok: ["Checks","TFLite","conversion","and","inference","."]
code: def testKerasAndTflite(
      self, vocab, lower_case_nfd_strip_accents, text_inputs
  ):
      """Checks TFLite conversion and inference."""
  
      class TextTokenizerModel(tf.keras.Model):
          def __init__(
              self, vocab, lower_case_nfd_strip_accents=False, **kwargs
          ):
              super().__init__(**kwargs)
              self.fast_bert_tokenizer = fast_bert_tokenizer.FastBertTokenizer(
                  vocab=vocab,
                  lower_case_nfd_strip_accents=lower_case_nfd_strip_accents,
              )
  
          def call(self, input_tensor, **kwargs):
              tokens = self.fast_bert_tokenizer.tokenize(input_tensor)
              return tokens.flat_values
  
      # Define a Keras model.
      model = TextTokenizerModel(
          vocab=vocab,
          lower_case_nfd_strip_accents=lower_case_nfd_strip_accents,
      )
      # Build the Keras model by doing an inference.
      model(np.array(text_inputs))
  
      # Convert to TFLite.
      converter = tf.lite.TFLiteConverter.from_keras_model(model)
      converter.target_spec.supported_ops = [
          tf.lite.OpsSet.TFLITE_BUILTINS
      ]
      converter.allow_custom_ops = True
      tflite_model = converter.convert()
  
      # Setup the TFLite interpreter.
      interp = interpreter.InterpreterWithCustomOps(
          model_content=tflite_model,
          custom_op_registerers=tf_text.tflite_registrar.SELECT_TFTEXT_OPS,
      )
      interp.allocate_tensors()
      input_details = interp.get_input_details()
      output_details = interp.get_output_details()
  
      # Do TF.Text and TFLite inference.
      # TFLite only supports batch_size=1. So we construct a single-element input
      # array.
      test_data = np.array([text_inputs[0]])
      tf_result = model(test_data)
  
      interp.set_tensor(input_details[0]["index"], test_data)
      interp.invoke()
      tflite_result = interp.get_tensor(output_details[0]["index"])
  
      # Assert the results are identical.
      self.assertAllEqual(tflite_result, tf_result)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_text
  from tensorflow.lite.python import interpreter
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import test_util
  from tensorflow.python.platform import test
  from tensorflow_text.python.ops import fast_bert_tokenizer
label_desc: Use image node_id 1 for calling the FastBertTokenizerKerasModelTest obj's underlying member method code with example usage: obj.testKerasAndTflite(vocab, lower_case_nfd_strip_accents, text_inputs) and returns: tokens