docstr: Checks TFLite conversion and inference.
docstr_tok: ["Checks","TFLite","conversion","and","inference","."]
code: def DISABELD_testKerasAndTflite(
      self, lower_case_nfd_strip_accents, text_inputs
  ):
      """Checks TFLite conversion and inference."""
  
      class TextNormalizerModel(tf.keras.Model):
          def __init__(
              self, lower_case_nfd_strip_accents=False, **kwargs
          ):
              super().__init__(**kwargs)
              self.normalizer = fast_bert_normalizer.FastBertNormalizer(
                  lower_case_nfd_strip_accents=lower_case_nfd_strip_accents
              )
  
          def call(self, input_tensor, **kwargs):
              return self.normalizer.normalize(input_tensor)
  
      # Define a Keras model.
      model = TextNormalizerModel(
          lower_case_nfd_strip_accents=lower_case_nfd_strip_accents
      )
      # Build the Keras model by doing 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.
      for text in text_inputs:
          test_data = np.array(
              [text]
          )  # Construct a single-element input array.
          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 absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_text
  from tensorflow.lite.python import interpreter
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import string_ops
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.platform import test
  from tensorflow_text.core.pybinds import pywrap_fast_bert_normalizer_model_builder
  from tensorflow_text.python.ops import fast_bert_normalizer
  from tensorflow_text.python.ops import normalize_ops
label_desc: Use image node_id 1 for calling the FastBertNormalizerKerasModelTest obj's underlying member method code with example usage: obj.DISABELD_testKerasAndTflite(lower_case_nfd_strip_accents, text_inputs) and returns: self