code: def update_embeddings(
      stop_event, model_path, model, neighbor_cache_client, dataset
  ):
      """Updates embeddings in knowledge bank server.
  
      This runs in a background thread, loads the latest unused checkpoint,
      then runs inference on all available data, updates corresponding embeddings
      in the knowledge bank server.
  
      Args:
        stop_event: `threading.Event` object used to stop updating the embeddings.
        model_path: path to the saved model.
        model: `GraphRegularizationWithCaching` object for inference.
        neighbor_cache_client: `NeighborCacheClient` object to update embeddings.
        dataset: dataset for inference to update.
      """
      logging.info("Start embedding updates")
      last_used_ckpt_path = None
  
      def update_embedding_fn(features, label):
          if not stop_event.wait(0.01):
              neighbor_cache_client.update(
                  features["id"], model.base_model(features)
              )
          return features, label
  
      # Keep updating until stop_event set to True.
      while not stop_event.wait(0.1):
          # Keep waiting to load the latest checkpoint until it exists.
          while not stop_event.wait(0.1):
              try:
                  latest_ckpt_path = tf.train.latest_checkpoint(
                      model_path
                  )
                  if last_used_ckpt_path != latest_ckpt_path:
                      # No new checkpoint since the last update.
                      last_used_ckpt_path = latest_ckpt_path
                      model.load_weights(latest_ckpt_path)
                      break
              except tf.errors.NotFoundError:
                  pass
  
          # Run inference on the dataset and update embeddings.
          dataset.map(update_embedding_fn)
  
      logging.info("Finished embedding updates")
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import threading
  from absl import app
  from absl import flags
  from absl import logging
  import attr
  import neural_structured_learning
  from research.carls import dynamic_embedding_config_pb2
  from research.carls import dynamic_embedding_neighbor_cache
  from research.carls import graph_regularization
  from research.carls import kbs_server_helper_pybind
  import tensorflow
  from google.protobuf import text_format
label_desc: Use image node_id 12 for calling a global function with example usage: update_embeddings(stop_event, model_path, model, neighbor_cache_client, dataset) and returns: features,  label