docstr: Verifies evaluation results for the graph-regularized model.
docstr_tok: ["Verifies","evaluation","results","for","the","graph-regularized","model","."]
code: def _train_and_check_eval_results(
      self, train_example, test_example, max_neighbors, weight, bias
  ):
      """Verifies evaluation results for the graph-regularized model."""
  
      def embedding_fn(features, unused_mode):
          # Computes y = w*x
          with tf.variable_scope(
              tf.get_variable_scope(),
              reuse=tf.AUTO_REUSE,
              auxiliary_name_scope=False,
          ):
              weight_tensor = tf.reshape(
                  tf.get_variable(
                      WEIGHT_VARIABLE,
                      shape=[2, 1],
                      partitioner=tf.fixed_size_partitioner(1),
                  ),
                  shape=[-1, 2],
              )
  
          x_tensor = tf.reshape(features[FEATURE_NAME], shape=[-1, 2])
          return tf.reduce_sum(
              tf.multiply(weight_tensor, x_tensor), 1, keep_dims=True
          )
  
      def optimizer_fn():
          return tf.train.GradientDescentOptimizer(LEARNING_RATE)
  
      base_est = self.build_linear_regressor(
          weight=weight, weight_shape=[2, 1], bias=bias, bias_shape=[1]
      )
  
      graph_reg_config = nsl_configs.make_graph_reg_config(
          max_neighbors=max_neighbors, multiplier=1
      )
      graph_reg_est = nsl_estimator.add_graph_regularization(
          base_est,
          embedding_fn,
          optimizer_fn,
          graph_reg_config=graph_reg_config,
      )
  
      train_input_fn = single_example_input_fn(
          train_example, input_shape=[2], max_neighbors=max_neighbors
      )
      graph_reg_est.train(input_fn=train_input_fn, steps=1)
  
      # Evaluating the graph-regularized model should yield the same results
      # as evaluating the base model because model paramters are shared.
      eval_input_fn = single_example_input_fn(
          test_example, input_shape=[2], max_neighbors=0
      )
      graph_eval_results = graph_reg_est.evaluate(
          input_fn=eval_input_fn
      )
      base_eval_results = base_est.evaluate(input_fn=eval_input_fn)
      self.assertAllClose(base_eval_results, graph_eval_results)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import shutil
  import tempfile
  import neural_structured_learning.configs
  import neural_structured_learning.estimator
  import numpy
  import tensorflow
  from tensorflow import estimator
  from google.protobuf import text_format
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 8 for calling the GraphRegularizationTest obj's underlying member method code with example usage: obj._train_and_check_eval_results(train_example, test_example, max_neighbors, weight, bias) and returns: tf, tf