class_docstr: Graph regularization class with support for caching neighbor state.
  
  It requires an instance of `NeighborCacheClient` to issue lookup and update
  operations to the neighbor cache.
  
  Example usage:
  
  ```python
  # Create a base model using the sequential, functional, or subclass API.
  base_model = tf.keras.Sequential(...)
  
  # Create a NeighborCacheClient object that implements the abstract methods.
  class NeighborCacheClientImpl(carls.NeighborCacheClient):
    def lookup(self, neighbor_ids):
      Send lookup request to cache server, and return the result.
  
    def update(self, neighbor_ids, neighbor_state):
      Send update request to the cache server.
  
  # Wrap the base model to include graph regularization using up to 1 neighbor
  # per sample.
  neighbor_cache_client = NeighborCacheClientImpl()
  graph_config = nsl.configs.make_graph_reg_config(max_neighbors=1)
  graph_model = carls.GraphRegularizationWithCaching(
      base_model, graph_config, neighbor_cache_client)
  
  # Compile, train, and evaluate the graph-regularized model as usual.
  graph_model.compile(
      optimizer='adam',
      loss=tf.keras.losses.SparseCategoricalCrossentropy(),
      metrics=['accuracy'])
  graph_model.fit(train_dataset, epochs=5)
  graph_model.evaluate(test_dataset)
  ```
docstr: Gets the logits for neighbor examples.
docstr_tok: ["Gets","the","logits","for","neighbor","examples","."]
code: def _get_neighbor_logits(self, nbr_features, training, **kwargs):
      """Gets the logits for neighbor examples."""
      nbr_logits = None
      if self.neighbor_cache_client:
          # Squeezes lookup keys from [(B*N), 1] to [B*N] to make the shape of
          # nbr_logits compatible with nbr_weights.
          nbr_lookup_keys = tf.squeeze(
              nbr_features[self.neighbor_cache_client.key_feature_name]
          )
          nbr_logits = self.neighbor_cache_client.lookup(
              nbr_lookup_keys
          )
      if nbr_logits is None:
          nbr_logits = self._infer_and_update(
              nbr_features, training=training, **kwargs
          )
      return nbr_logits
  
file_path: neural-structured-learning/research/carls/graph_regularization.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from neural_structured_learning.keras import graph_regularization
  import tensorflow
label_desc: Use image node_id 3 for calling the GraphRegularizationWithCaching obj's underlying member method code with example usage: obj._get_neighbor_logits(nbr_features, training) and returns: nbr_logits