class_docstr: Representative dataset saver in TFRecord format.
  
  Saves representative datasets for quantization calibration in TFRecord format.
  The samples are serialized as `RepresentativeDataSample`.
  
  The `save` method return a signature key to `RepresentativeDatasetFile` map,
  which can be used for QuantizationOptions.
  
  Example usage:
  
  ```python
  # Creating the representative dataset.
  representative_dataset = [{"input": tf.random.uniform(shape=(3, 3))}
                        for _ in range(256)]
  
  # Saving to a TFRecord file.
  dataset_file_map = (
    tf.quantization.experimental.TfRecordRepresentativeDatasetSaver(
          path_map={'serving_default': '/tmp/representative_dataset_path'}
      ).save({'serving_default': representative_dataset})
  )
  
  # Using in QuantizationOptions.
  quantization_options = tf.quantization.experimental.QuantizationOptions(
      signature_keys=['serving_default'],
      representative_datasets=dataset_file_map,
  )
  tf.quantization.experimental.quantize_saved_model(
      '/tmp/input_model',
      '/tmp/output_model',
      quantization_options=quantization_options,
  )
  ```
class_docstr_tok: ["Representative","dataset","saver","in","TFRecord","format",".","Saves","representative","datasets","for","quantization","calibration","in","TFRecord","format",".","The","samples","are","serialized","as","`","RepresentativeDataSample","`",".","The","`","save","`","method","return","a","signature","key","to","`","RepresentativeDatasetFile","`","map",",","which","can","be","used","for","QuantizationOptions",".","Example","usage",":","``","`","python","#","Creating","the","representative","dataset",".","representative_dataset","=","[","{","``","input","''",":","tf.random.uniform","(","shape=","(","3",",","3",")",")","}","for","_","in","range","(","256",")","]","#","Saving","to","a","TFRecord","file",".","dataset_file_map","=","(","tf.quantization.experimental.TfRecordRepresentativeDatasetSaver","(","path_map=","{","'serving_default","'",":","'\/tmp\/representative_dataset_path","'","}",")",".save","(","{","'serving_default","'",":","representative_dataset","}",")",")","#","Using","in","QuantizationOptions",".","quantization_options","=","tf.quantization.experimental.QuantizationOptions","(","signature_keys=","[","'serving_default","'","]",",","representative_datasets=dataset_file_map",",",")","tf.quantization.experimental.quantize_saved_model","(","'\/tmp\/input_model","'",",","'\/tmp\/output_model","'",",","quantization_options=quantization_options",",",")","``","`"]
docstr: Saves the representative dataset.
  
  Args:
    representative_dataset: Signature def key -> representative dataset
      mapping. Each dataset is saved in a separate TFRecord file whose path
      matches the signature def key of `path_map`.
  
  Raises:
    ValueError: When the signature def key in `representative_dataset` is not
    present in the `path_map`.
  
  Returns:
    A map from signature key to the RepresentativeDatasetFile instance
    contains the path to the saved file.
docstr_tok: ["Saves","the","representative","dataset",".","Args",":","representative_dataset",":","Signature","def","key","-",">","representative","dataset","mapping",".","Each","dataset","is","saved","in","a","separate","TFRecord","file","whose","path","matches","the","signature","def","key","of","`","path_map","`",".","Raises",":","ValueError",":","When","the","signature","def","key","in","`","representative_dataset","`","is","not","present","in","the","`","path_map","`",".","Returns",":","A","map","from","signature","key","to","the","RepresentativeDatasetFile","instance","contains","the","path","to","the","saved","file","."]
code: def save(
      self, representative_dataset: RepresentativeDatasetMapping
  ) -> Mapping[str, _RepresentativeDatasetFile]:
      """Saves the representative dataset.
  
      Args:
        representative_dataset: Signature def key -> representative dataset
          mapping. Each dataset is saved in a separate TFRecord file whose path
          matches the signature def key of `path_map`.
  
      Raises:
        ValueError: When the signature def key in `representative_dataset` is not
        present in the `path_map`.
  
      Returns:
        A map from signature key to the RepresentativeDatasetFile instance
        contains the path to the saved file.
      """
      dataset_file_map = {}
      for signature_def_key, repr_ds in representative_dataset.items():
          if signature_def_key not in self.path_map:
              raise ValueError(
                  "SignatureDef key does not exist in the provided path_map:"
                  f" {signature_def_key}"
              )
  
          dataset_file_map[
              signature_def_key
          ] = self._save_tf_record_dataset(repr_ds, signature_def_key)
      return dataset_file_map
  
imports: import collections.abc
  import os
  from typing import Iterable, Mapping, Optional, Union
  import numpy
  from tensorflow.compiler.mlir.quantization.tensorflow import quantization_options_pb2
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.python.client import session
  from tensorflow.python.data.ops import readers
  from tensorflow.python.eager import context
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.lib.io import python_io
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.types import core
  from tensorflow.python.util import tf_export
label_desc: Use image node_id 3 for calling the TfRecordRepresentativeDatasetSaver obj's underlying member method code with example usage: obj.save(representative_dataset) and returns: dataset_file_map