code: def _generate_integer_tflite_model(
      quantization_type=dtypes.int8,
      use_saved_model=False,
      saved_model_dir=None,
      add_unquantizable_layer=False,
  ):
      """Define an integer post-training quantized tflite model."""
  
      model = _get_keras_model(add_unquantizable_layer)
      if not use_saved_model:
          # Convert TF Model to an Integer Quantized TFLite Model
          converter = tf.lite.TFLiteConverter.from_keras_model(model)
      else:
          model.save(saved_model_dir)
          converter = tf.lite.TFLiteConverter.from_saved_model(
              saved_model_dir
          )
      converter.optimizations = {tf.lite.Optimize.DEFAULT}
  
      def representative_dataset_gen():
          for _ in range(2):
              yield [
                  np.random.uniform(
                      low=0, high=1, size=(1, 28, 28)
                  ).astype(np.float32)
              ]
  
      converter.representative_dataset = representative_dataset_gen
      if quantization_type == dtypes.int8:
          converter.target_spec.supported_ops = {
              tf.lite.OpsSet.TFLITE_BUILTINS_INT8
          }
      else:
          converter.target_spec.supported_ops = {
              tf.lite.OpsSet.EXPERIMENTAL_TFLITE_BUILTINS_ACTIVATIONS_INT16_WEIGHTS_INT8
          }
      tflite_model = converter.convert()
  
      return tflite_model
  
imports: import os
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow.lite.python import util
  from tensorflow.lite.tools.flatbuffer_utils import read_model
  from tensorflow.python.client import session
  from tensorflow.python.framework import convert_to_constants
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import while_loop
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling a global function with example usage: _generate_integer_tflite_model(quantization_type, use_saved_model, saved_model_dir, add_unquantizable_layer) and returns: tflite_model