code: def _create_sample_validator(
      expected_input_keys: Collection[str],
  ) -> Callable[[rd.RepresentativeSample], rd.RepresentativeSample]:
      """Creates a validator function for a representative sample.
  
      Args:
        expected_input_keys: Input keys (keyword argument names) that the function
          the sample will be used for is expecting to receive.
  
      Returns:
        A callable that validates a `RepresentativeSample`.
      """
  
      def validator(
          sample: rd.RepresentativeSample,
      ) -> rd.RepresentativeSample:
          """Validates a single instance of representative sample.
  
          This provides a simple check for `sample` that this is a mapping of
          {input_key: input_value}.
  
          Args:
            sample: A `RepresentativeSample` to validate.
  
          Returns:
            `sample` iff it is valid.
  
          Raises:
            ValueError: iff the sample isn't an instance of `Mapping`.
            KeyError: iff the sample does not have the set of input keys that match
              the input keys of the function.
          """
          if not isinstance(sample, Mapping):
              raise ValueError(
                  "Invalid representative sample type. Provide a mapping "
                  "(usually a dict) of {input_key: input_value}. "
                  f"Got type: {type(sample)} instead."
              )
  
          if set(sample.keys()) != expected_input_keys:
              raise KeyError(
                  "Invalid input keys for representative sample. The function expects "
                  f"input keys of: {set(expected_input_keys)}. "
                  f"Got: {set(sample.keys())}. Please provide correct input keys for "
                  "representative samples."
              )
  
          return sample
  
      return validator
  
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 5 for calling a global function with example usage: _create_sample_validator(expected_input_keys) and returns: validator, sample