code: def _validate_representative_dataset(
      representative_dataset: rd.RepresentativeDatasetOrMapping,
      signature_keys: Collection[str],
  ) -> None:
      """Validates the representative dataset, based on the signature keys.
  
      Representative dataset can be provided in two different forms: a single
      instance of `RepresentativeDataset` or a map of signature key to the
      corresponding `RepresentativeDataset`. These have a relationship with
      `signature_keys`.
  
      This function validates the following conditions:
      * If `len(signature_keys) > 1`, then `representative_dataset` should be a
        mapping where the keys exactly match the elements in `signature_keys`.
      * If `len(signature_keys) == 1`, then both a mapping and a single instance of
        `RepresentativeDataset` are allowed.
      * This function also assumes `len(signature_keys) > 0`.
  
      Args:
        representative_dataset: A `RepresentativeDataset` or a map of string to
          `RepresentativeDataset` to be validated.
        signature_keys: A collection of strings that contains the signature keys,
          each identifying a `SignatureDef`.
  
      Raises:
        ValueError: Iff `representative_dataset` does not satisfy the conditions
          above.
      """
      if isinstance(representative_dataset, Mapping):
          if set(signature_keys) != set(representative_dataset.keys()):
              raise ValueError(
                  "The signature keys and the keys of representative dataset map "
                  f"do not match. Signature keys: {set(signature_keys)}, "
                  f"representative dataset map: {set(representative_dataset.keys())}."
              )
      else:
          if len(signature_keys) > 1:
              raise ValueError(
                  "Representative dataset is not a mapping "
                  f"(got: {type(representative_dataset)}), "
                  "but there is more than one signature key provided. "
                  "Please provide a map of {signature_key -> dataset} "
                  "with more than one signature key."
              )
  
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 3 for calling a global function with example usage: _validate_representative_dataset(representative_dataset, signature_keys) without return types