code: def _test_training_with_two_neighbors(
      self, dense_layer_index, model_fn, distributed_strategy=None
  ):
      w = np.array([[4.0], [-3.0]])
      x0 = np.array([[2.0, 3.0]])
      x0_nbr0 = np.array([[2.5, 3.0]])
      x0_nbr1 = np.array([[2.0, 2.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: "NL_nbr_1_x"
                      value: { float_list { value: [ 2.0, 2.0 ] } }
                    }
                    feature {
                      key: "NL_nbr_1_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_nbr0 = np.dot(x0_nbr0, w)  # 1.0
      y_nbr1 = np.dot(x0_nbr1, w)  # 2.0
  
      # The distance metric for the graph loss is 'L2'. So, the graph loss term is
      # [(y_hat - y_nbr_0)^2 + (y_hat - y_nbr_1)^2] / 2
      grad_w = (
          2 * (y_hat - y0) * x0.T
          + (y_hat - y_nbr0) * (x0 - x0_nbr0).T
          + (y_hat - y_nbr1) * (x0 - x0_nbr1).T
      )  # [[-3.0], [-9.0]]
  
      self._train_and_check_params(
          example,
          model_fn,
          dense_layer_index,
          max_neighbors=2,
          weight=w,
          expected_grad_from_weight=grad_w,
          distributed_strategy=distributed_strategy,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from absl.testing import parameterized
  from neural_structured_learning import configs
  from neural_structured_learning.keras import graph_regularization
  import numpy
  import tensorflow
  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._test_training_with_two_neighbors(dense_layer_index, model_fn, distributed_strategy) without return types