code: def convert(
      model_flags: _model_flags_pb2.ModelFlags,
      conversion_flags: _conversion_flags_pb2.TocoFlags,
      input_data_str: Optional[str] = None,
      debug_info_str: Optional[str] = None,
      enable_mlir_converter: bool = True,
  ):
      """Converts `input_data_str` to a TFLite model.
  
      Args:
        model_flags: Proto describing model properties, see `model_flags.proto`.
        conversion_flags: Proto describing conversion properties, see
          `toco/toco_flags.proto`.
        input_data_str: Input data in serialized form (e.g. a graphdef is common, or
          it can be hlo text or proto)
        debug_info_str: Serialized `GraphDebugInfo` proto describing logging
          information.
        enable_mlir_converter: Enables MLIR-based conversion.
  
      Returns:
        Converted model in serialized form (e.g. a TFLITE model is common).
      Raises:
        ConverterError: When conversion fails in TFLiteConverter, usually due to
          ops not being supported.
        RuntimeError: When conversion fails, an exception is raised with the error
          message embedded.
      """
      # Historically, deprecated conversion failures would trigger a crash, so we
      # attempt to run the converter out-of-process. The current MLIR conversion
      # pipeline surfaces errors instead, and can be safely run in-process.
      if enable_mlir_converter or not _deprecated_conversion_binary:
          try:
              return wrap_toco.wrapped_toco_convert(
                  model_flags.SerializeToString(),
                  conversion_flags.SerializeToString(),
                  input_data_str,
                  debug_info_str,
                  enable_mlir_converter,
              )
          except Exception as e:
              converter_error = ConverterError(str(e))
  
              for (
                  error_data
              ) in _metrics_wrapper.retrieve_collected_errors():
                  converter_error.append_error(error_data)
                  # Seldom we encounter the case where an unsupported
                  # `StatefulPartitionedCallOp` is not inlined and remains in the final
                  # IR. If this occurs we can set `guarantee_all_funcs_one_use` and retry.
                  # This makes the converter copy functions definitions called by
                  # multiple StatefulPartitionedCall, thus allowing them to be properly
                  # inlined.
                  if (
                      error_data.error_code
                      == converter_error_data_pb2.ConverterErrorData.ERROR_STATEFUL_PARTITIONED_CALL_IN_FINAL_IR
                      and not conversion_flags.guarantee_all_funcs_one_use
                  ):
                      conversion_flags.guarantee_all_funcs_one_use = (
                          True
                      )
                      return convert(
                          model_flags,
                          conversion_flags,
                          input_data_str,
                          debug_info_str,
                          enable_mlir_converter,
                      )
              raise converter_error
  
      return _run_deprecated_conversion_binary(
          model_flags.SerializeToString(),
          conversion_flags.SerializeToString(),
          input_data_str,
          debug_info_str,
      )
  
imports: import distutils.spawn
  import enum
  import hashlib
  import os
  import platform
  import subprocess
  import tempfile
  from typing import Optional
  import warnings
  from tensorflow.compiler.mlir.quantization.stablehlo import quantization_options_pb2
  from tensorflow.lite.python import lite_constants
  from tensorflow.lite.python import util
  from tensorflow.lite.python import wrap_toco
  from tensorflow.lite.python.convert_phase import Component
  from tensorflow.lite.python.convert_phase import convert_phase
  from tensorflow.lite.python.convert_phase import ConverterError
  from tensorflow.lite.python.convert_phase import SubComponent
  from tensorflow.lite.python.metrics import converter_error_data_pb2
  from tensorflow.lite.python.metrics.wrapper import metrics_wrapper
  from tensorflow.lite.toco import model_flags_pb2
  from tensorflow.lite.toco import toco_flags_pb2
  from tensorflow.lite.toco import types_pb2
  from tensorflow.lite.tools import flatbuffer_utils
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.platform import resource_loader
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 8 for calling a global function with example usage: convert(model_flags, conversion_flags, input_data_str, debug_info_str, enable_mlir_converter) and returns: _run_deprecated_conversion_binary, wrap_toco, convert