code: def _convert_to_tflite(
      saved_model_dir, num_styles, image_size, quantize, output_model
  ):
      """Convert a image stylization saved model to TensorFlow Lite format."""
      # Append filename if output_model is a directory name
      if tf.io.gfile.isdir(output_model):
          if quantize:
              filename = "stylize_quantized.tflite"
          else:
              filename = "stylize.tflite"
          output_model = os.path.join(output_model, filename)
  
      # Initialize TF Lite Converter
      converter = tf.lite.TFLiteConverter.from_saved_model(
          saved_model_dir=saved_model_dir,
          input_shapes={
              "input_image": [None, image_size, image_size, 3],
              "style_weights": num_styles,
          },
      )
  
      # Specify quantization option
      if quantize:
          converter.optimizations = [tf.lite.Optimize.DEFAULT]
  
      # Convert and save the TF Lite model
      tflite_model = converter.convert()
      with tf.io.gfile.GFile(output_model, "wb") as f:
          f.write(tflite_model)
      tf.logging.info(
          "Converted to TF Lite model: %s; Size: %d KB."
          % (output_model, len(tflite_model) / 1024)
      )
  
file_path: magenta/magenta/models/image_stylization/image_stylization_convert_tflite.py
imports: import os
  import tempfile
  from magenta.models.image_stylization import model
  from magenta.models.image_stylization import ops
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling a global function with example usage: _convert_to_tflite(saved_model_dir, num_styles, image_size, quantize, output_model) without return types