code: def _read_tfrecord_examples(
      filenames, id_feature_name, embedding_feature_name
  ):
      """Reads and returns the embeddings stored in the Examples in `filename`.
  
      Args:
        filenames: A list of names of TFRecord files containing `tf.train.Example`
          objects.
        id_feature_name: Name of the feature that identifies the Example's ID.
        embedding_feature_name: Name of the feature that identifies the Example's
          embedding.
  
      Returns:
        A dict mapping each instance ID to its L2-normalized embedding, represented
        by a 1-D numpy.ndarray. The ID is expected to be contained in the singleton
        bytes_list feature named by 'id_feature_name', and the embedding is
        expected to be contained in the float_list feature named by
        'embedding_feature_name'.
      """
  
      def parse_tf_record_examples(filename):
          """Generator that returns the tensorflow.Examples in `filename`.
  
          Args:
            filename: Name of the TFRecord file containing tensorflow.Examples.
  
          Yields:
            The tensorflow.Examples contained in the file.
          """
          for raw_record in tf.data.TFRecordDataset([filename]):
              example = tf.train.Example()
              example.ParseFromString(raw_record.numpy())
              yield example
  
      def l2_normalize(v):
          """Returns the L2-norm of the vector `v`.
  
          Args:
            v: A 1-D vector (either a list or numpy array).
  
          Returns:
            The L2-normalized version of `v`. The result will have an L2-norm of 1.0.
          """
          l2_norm = np.linalg.norm(v)
          return v / max(l2_norm, _MIN_NORM)
  
      embeddings = {}
      for filename in filenames:
          start_time = time.time()
          logging.info(
              "Reading tf.train.Examples from TFRecord file: %s...",
              filename,
          )
          for tf_example in parse_tf_record_examples(filename):
              f_map = tf_example.features.feature
              if id_feature_name not in f_map:
                  logging.error(
                      'No feature named "%s" found in input Example: %s',
                      id_feature_name,
                      tf_example.ShortDebugString(),
                  )
                  continue
              ex_id = (
                  f_map[id_feature_name]
                  .bytes_list.value[0]
                  .decode("utf-8")
              )
              if embedding_feature_name not in f_map:
                  logging.error(
                      'No feature named "%s" found in input with ID "%s"',
                      embedding_feature_name,
                      ex_id,
                  )
                  continue
              embedding_list = f_map[
                  embedding_feature_name
              ].float_list.value
              embeddings[ex_id] = l2_normalize(embedding_list)
          logging.info(
              "Done reading %d tf.train.Examples from: %s (%.2f seconds).",
              len(embeddings),
              filename,
              time.time() - start_time,
          )
      return embeddings
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  import time
  from absl import app
  from absl import flags
  from absl import logging
  import neural_structured_learning.configs
  import numpy
  import six
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: _read_tfrecord_examples(filenames, id_feature_name, embedding_feature_name) and returns: embeddings, unknown