code: def _run_graph_for_calibration(
      float_model_dir: str,
      signature_keys: Sequence[str],
      tags: Collection[str],
      representative_dataset: rd.RepresentativeDatasetOrMapping,
      force_graph_mode_calibration: bool,
  ) -> None:
      """Runs the graph for calibration using representative datasets.
  
      Args:
        float_model_dir: Path to the model to calibrate.
        signature_keys: Sequence of keys identifying SignatureDef containing inputs
          and outputs.
        tags: Collection of tags identifying the MetaGraphDef within the SavedModel
          to analyze.
        representative_dataset: An iterator that returns a dictionary of {input_key:
          input_value} or a mapping from signature keys to such iterators. When
          `signature_keys` contains more than one signature key,
          `representative_datsaet` should be a mapping that maps each signature keys
          to the corresponding representative dataset.
        force_graph_mode_calibration: If set to true, it forces calibration in graph
          model instead of eager mode when the context is in eager mode.
  
      Raises:
        ValueError iff:
          * The representative dataset format is invalid.
          * It fails to run the functions using the representative datasets.
      """
      try:
          _validate_representative_dataset(
              representative_dataset, signature_keys
          )
      except Exception as ex:
          raise ValueError("Invalid representative dataset.") from ex
  
      # If `representative_dataset` is not a mapping, convert to a mapping for the
      # following functions to handle representative datasets more conveniently.
      representative_dataset_map = representative_dataset
      if not isinstance(representative_dataset, Mapping):
          # `signature_keys` is guaranteed to have only one element after the
          # validation.
          representative_dataset_map = {
              signature_keys[0]: representative_dataset
          }
  
      try:
          if (
              context.executing_eagerly()
              and not force_graph_mode_calibration
          ):
              logging.info(
                  "Calibration step is executed in eager mode."
              )
              _run_graph_for_calibration_eager_mode(
                  float_model_dir, tags, representative_dataset_map
              )
          else:
              logging.info(
                  "Calibration step is executed in graph mode."
              )
              _run_graph_for_calibration_graph_mode(
                  float_model_dir, tags, representative_dataset_map
              )
      except Exception as ex:
          raise ValueError(
              "Failed to run graph for post-training quantization calibration."
          ) from ex
  
      logging.info("Calibration step complete.")
  
imports: from collections.abc import Callable, Collection, Mapping, Sequence
  from typing import Optional
  from absl import logging
  from tensorflow.compiler.mlir.quantization.tensorflow import exported_model_pb2
  from tensorflow.compiler.mlir.quantization.tensorflow import quantization_options_pb2
  from tensorflow.compiler.mlir.quantization.tensorflow.calibrator import calibration_algorithm
  from tensorflow.compiler.mlir.quantization.tensorflow.calibrator import calibration_statistics_pb2
  from tensorflow.compiler.mlir.quantization.tensorflow.calibrator import pywrap_calibration
  from tensorflow.compiler.mlir.quantization.tensorflow.python import pywrap_function_lib
  from tensorflow.compiler.mlir.quantization.tensorflow.python import representative_dataset
  from tensorflow.compiler.mlir.quantization.tensorflow.python import save_model
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.core.protobuf import saver_pb2
  from tensorflow.python.client import session
  from tensorflow.python.eager import context
  from tensorflow.python.eager import wrap_function
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_conversion
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.saved_model import load
  from tensorflow.python.saved_model import loader_impl
  from tensorflow.python.trackable import autotrackable
  from tensorflow.python.types import core
label_desc: Use image node_id 12 for calling a global function with example usage: _run_graph_for_calibration(float_model_dir, signature_keys, tags, representative_dataset, force_graph_mode_calibration) without return types