code: def test_graph_reg_model_one_neighbor_training(
      self, dense_layer_index, model_fn
  ):
      w = np.array([[4.0], [-3.0]])
      x0 = np.array([[2.0, 3.0]])
      x0_nbr0 = np.array([[2.5, 3.0]])
      y0 = np.array([[0.0]])
  
      example = """
                  features {
                    feature {
                      key: "x"
                      value: { float_list { value: [ 2.0, 3.0 ] } }
                    }
                    feature {
                      key: "NL_nbr_0_x"
                      value: { float_list { value: [ 2.5, 3.0 ] } }
                    }
                    feature {
                      key: "NL_nbr_0_weight"
                      value: { float_list { value: 1.0 } }
                    }
                    feature {
                      key: "y"
                      value: { float_list { value: 0.0 } }
                    }
                  }
                """
  
      y_hat = np.dot(x0, w)  # -1.0
      y_nbr = np.dot(x0_nbr0, w)  # 1.0
  
      # The graph loss term is (y_hat - y_nbr)^2 since graph regularization is
      # done on the final predictions.
      grad_w = (
          2 * (y_hat - y0) * x0.T
          + 2 * (y_hat - y_nbr) * (x0 - x0_nbr0).T
      )  # [[-2.0], [-6.0]]
  
      self._train_and_check_params(
          example,
          model_fn,
          dense_layer_index,
          max_neighbors=1,
          weight=w,
          expected_grad_from_weight=grad_w,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  from neural_structured_learning import configs
  from research.carls import graph_regularization
  from research.carls import neighbor_cache_client
  import numpy
  import tensorflow
  from google.protobuf import text_format
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 4 for calling the GraphRegularizationWithCachingTest obj's underlying member method code with example usage: obj.test_graph_reg_model_one_neighbor_training(dense_layer_index, model_fn) without return types