docstr: Runs training for one step and verifies gradient-based updates.
docstr_tok: ["Runs","training","for","one","step","and","verifies","gradient-based","updates","."]
code: def _train_and_check_params(
      self,
      example,
      max_neighbors,
      weight,
      bias,
      expected_grad_from_weight,
      expected_grad_from_bias,
  ):
      """Runs training for one step and verifies gradient-based updates."""
  
      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,
      )
  
      input_fn = single_example_input_fn(
          example, input_shape=[2], max_neighbors=max_neighbors
      )
      graph_reg_est.train(input_fn=input_fn, steps=1)
  
      # Compute the new bias and weight values based on the gradients.
      expected_bias = bias - LEARNING_RATE * (expected_grad_from_bias)
      expected_weight = weight - LEARNING_RATE * (
          expected_grad_from_weight
      )
  
      # Check that the parameters of the linear regressor have the correct values.
      self.assertAllClose(
          expected_bias, graph_reg_est.get_variable_value(BIAS_VARIABLE)
      )
      self.assertAllClose(
          expected_weight,
          graph_reg_est.get_variable_value(WEIGHT_VARIABLE),
      )
  
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 5 for calling the GraphRegularizationTest obj's underlying member method code with example usage: obj._train_and_check_params(example, max_neighbors, weight, bias, expected_grad_from_weight, expected_grad_from_bias) and returns: tf, tf