code: def convert_keras_to_tflite(
      model,
      output_path,
      custom_objects=None,
      is_quantized=True,
      inference_type=None,
      inference_input_type=None,
      input_quant_params=(-128.0, 255.0),
  ):
      """Convert Keras model to TFLite."""
      if custom_objects is None:
          custom_objects = {}
  
      if not compat.is_v1_apis():
          converter = tf.lite.TFLiteConverter.from_keras_model(model)
      else:
          _, keras_file = tempfile.mkstemp(".h5")
          tf.keras.models.save_model(model, keras_file)
          converter = tf.lite.TFLiteConverter.from_keras_model_file(
              keras_file, custom_objects=custom_objects
          )
  
      if is_quantized:
          if not compat.is_v1_apis():
              converter.optimizations = [tf.lite.Optimize.DEFAULT]
          else:
              converter.inference_type = tf.lite.constants.INT8
              converter.inference_input_type = tf.lite.constants.FLOAT
              # TODO(tfmot): should be able to make everything use the
              # same inference_type in TF 1.X tests.
              if inference_type:
                  converter.inference_type = inference_type
              if inference_input_type:
                  converter.inference_input_type = inference_input_type
  
              input_arrays = converter.get_input_arrays()
              converter.quantized_input_stats = {
                  input_arrays[0]: input_quant_params
              }  # mean, std_dev values for float to quantized int8 values.
  
      tflite_model = converter.convert()
  
      if output_path is not None:
          with open(output_path, "wb") as f:
              f.write(tflite_model)
  
      return tflite_model
  
file_path: model-optimization/tensorflow_model_optimization/python/core/quantization/keras/utils.py
imports: import inspect
  import tempfile
  import tensorflow
  from tensorflow_model_optimization.python.core.keras import compat
label_desc: Use image node_id 7 for calling a global function with example usage: convert_keras_to_tflite(model, output_path, custom_objects, is_quantized, inference_type, inference_input_type, input_quant_params) and returns: tflite_model