code: def test_attri2vec_apply():
      attri2vec = Attri2Vec(
          layer_sizes=[2, 2, 2],
          bias=False,
          input_dim=2,
          node_num=4,
          multiplicity=2,
          activation="linear",
          normalize=None,
      )
  
      # the rest of the test assumes the weights are 1, to get the predictions to be easily computed,
      # so let's build a basic model to set those weights (which are stored statefully in Attri2vec)
      model = keras.Model(*attri2vec.in_out_tensors())
      model.set_weights([np.ones_like(w) for w in model.get_weights()])
  
      x = np.array([[1, 2]])
      expected = np.array([[12, 12]])
  
      inp = keras.Input(shape=(2,))
      out = attri2vec(inp)
      model1 = keras.Model(inputs=inp, outputs=out)
      actual = model1.predict(x)
      assert expected == pytest.approx(actual)
  
      # Use the node model:
      xinp, xout = attri2vec.in_out_tensors(multiplicity=1)
      model2 = keras.Model(inputs=xinp, outputs=xout)
      assert pytest.approx(expected) == model2.predict(x)
  
      x1 = np.array([[3, 1]])
      x2 = np.array([[2]])
      y1 = np.array([[16, 16]])
      y2 = np.array([[1, 1]])
  
      # Test the build function:
      xinp, xout = attri2vec.in_out_tensors()
      model3 = keras.Model(inputs=xinp, outputs=xout)
      actual = model3.predict([x1, x2])
      assert pytest.approx(y1) == actual[0]
      assert pytest.approx(y2) == actual[1]
  
      # Use the link model:
      xinp, xout = attri2vec.in_out_tensors()
      model4 = keras.Model(inputs=xinp, outputs=xout)
      actual = model4.predict([x1, x2])
      assert pytest.approx(y1) == actual[0]
      assert pytest.approx(y2) == actual[1]
  
file_path: stellargraph/tests/layer/test_attri2vec.py
imports: from stellargraph.core.graph import StellarGraph
  from stellargraph.mapper import Attri2VecNodeGenerator
  from stellargraph.layer.attri2vec import *
  from tensorflow import keras
  import numpy
  import networkx
  import pytest
  from ..test_utils.graphs import example_graph
  from ..None import test_utils
label_desc: Use image node_id 2 for calling a global function with example usage: test_attri2vec_apply() without return types