code: def validate_model_outputs(
      config: "TFLiteConfig",
      reference_model: "TFPreTrainedModel",
      tflite_model_path: Path,
      tflite_named_outputs: List[str],
      atol: Optional[float] = None,
  ):
      """
      Validates the export by checking that the outputs from both the reference and the exported model match.
  
      Args:
          config ([`~optimum.exporters.tflite.TFLiteConfig`]:
              The configuration used to export the model.
          reference_model ([`~TFPreTrainedModel`]):
              The model used for the export.
          tflite_model_path (`Path`):
              The path to the exported model.
          tflite_named_outputs (`List[str]`):
              The names of the outputs to check.
          atol (`Optional[float]`, defaults to `None`):
              The absolute tolerance in terms of outputs difference between the reference and the exported model.
  
      Raises:
          ValueError: If the outputs shapes or values do not match between the reference and the exported model.
      """
      if not is_tf_available():
          raise ImportError(
              "Cannot validate conversion because TensorFlow is not installed. "
              "Please install TensorFlow first."
          )
      import tensorflow as tf
  
      logger.info("Validating TFLite model...")
  
      if atol is None:
          if isinstance(config.ATOL_FOR_VALIDATION, dict):
              atol = config.ATOL_FOR_VALIDATION[config.task]
          else:
              atol = config.ATOL_FOR_VALIDATION
  
      inputs = config.generate_dummy_inputs()
  
      ref_outputs = reference_model(**inputs)
  
      interpreter = tf.lite.Interpreter(
          model_path=tflite_model_path.as_posix()
      )
      tflite_model_runner = interpreter.get_signature_runner("model")
      tflite_outputs = tflite_model_runner(**inputs)
  
      # Check we have a subset of the keys into onnx_outputs against ref_outputs
      ref_outputs_set, tflite_output_set = set(ref_outputs.keys()), set(
          tflite_named_outputs
      )
      if not tflite_output_set.issubset(ref_outputs_set):
          raise OutputMatchError(
              "TFLite model output names do not match reference model output names.\n"
              f"Reference model output names: {ref_outputs_set}\n"
              f"TFLite model output names: {tflite_output_set}"
              f"Difference: {tflite_output_set.difference(ref_outputs_set)}"
          )
      else:
          tflite_output_names = ", ".join(tflite_output_set)
          logger.info(
              f"\t-[✓] TFLite model output names match reference model ({tflite_output_names})"
          )
  
      # Check the shape and values match
      shape_failures = []
      value_failures = []
      for name, output in tflite_outputs.items():
          if name not in tflite_output_set:
              continue
  
          ref_output = ref_outputs[name].numpy()
  
          logger.info(f'\t- Validating TFLite Model output "{name}":')
  
          # Shape
          if not output.shape == ref_output.shape:
              logger.error(
                  f"\t\t-[x] shape {output.shape} doesn't match {ref_output.shape}"
              )
              shape_failures.append(
                  (name, ref_output.shape, output.shape)
              )
          else:
              logger.info(
                  f"\t\t-[✓] {output.shape} matches {ref_output.shape}"
              )
  
          # Values
          if not np.allclose(ref_output, output, atol=atol):
              max_diff = np.amax(np.abs(ref_output - output))
              logger.error(
                  f"\t\t-[x] values not close enough, max diff: {max_diff} (atol: {atol})"
              )
              value_failures.append((name, max_diff))
          else:
              logger.info(f"\t\t-[✓] all values close (atol: {atol})")
  
      if shape_failures:
          msg = "\n".join(
              f"- {t[0]}: got {t[1]} (reference) and {t[2]} (TFLite)"
              for t in shape_failures
          )
          raise ShapeError(
              "Output shapes do not match between reference model and the TFLite exported model:\n"
              "{msg}"
          )
  
      if value_failures:
          msg = "\n".join(
              f"- {t[0]}: max diff = {t[1]}" for t in value_failures
          )
          raise AtolError(
              "The maximum absolute difference between the output of the reference model and the TFLite "
              f"exported model is not within the set tolerance {atol}:\n{msg}"
          )
  
file_path: optimum/optimum/exporters/tflite/convert.py
imports: from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple
  import numpy
  from transformers import PreTrainedTokenizerBase
  from transformers.utils import is_tf_available
  from ...utils import logging
  from ...utils.preprocessing import Preprocessor, TaskProcessorsManager
  from ..error_utils import AtolError, OutputMatchError, ShapeError
  from .base import QuantizationApproach, QuantizationApproachNotSupported
label_desc: Use image node_id 1 for calling a global function with example usage: validate_model_outputs(config, reference_model, tflite_model_path, tflite_named_outputs, atol) without return types