code: def test_attn_agg_apply():
      agg = AttentionalAggregator(
          2, bias=False, act="linear", kernel_initializer="ones"
      )
      agg.attn_act = keras.activations.get("linear")
  
      # Self features
      inp1 = keras.Input(shape=(1, 2))
      # Neighbour features
      inp2 = keras.Input(shape=(1, 2, 2))
      out = agg([inp1, inp2])
  
      # The AttentionalAggregator implementation is a hack at the moment, it doesn't
      # assign any dimensions in the output to head-node features.
      assert agg.weight_dims == [0, 2]
  
      # Numerical test values
      x1 = np.array([[[1, 1]]])
      x2 = np.array([[[[2, 2], [3, 3]]]])
  
      # Agg output:
      # hs = relu(x1 · ones(2x2)) = [2,2]
      # hn = relu(x2 · ones(2x2)) =  [[2,2], [4,4], [6,6]]
      # attn_u = ones(2) · hs +  ones(2) · hn = [8, 12, 16]
      # attn = softmax(attn_u) = [3.3e-4, 1.8e-4, 9.81e-1]
      # hout =  attn · hn = [5.96, 5.96]
      model = keras.Model(inputs=[inp1, inp2], outputs=out)
      actual = model.predict([x1, x2])
  
      expected = np.array([[[5.963, 5.963]]])
  
      assert expected == pytest.approx(actual, rel=1e-4)
  
imports: from tensorflow import keras
  from tensorflow.keras import initializers, regularizers
  import tensorflow
  import numpy
  import pytest
  from stellargraph.mapper import GraphSAGENodeGenerator
  from stellargraph.layer.graphsage import GraphSAGE, MeanAggregator, MaxPoolingAggregator, MeanPoolingAggregator, AttentionalAggregator
  from ..test_utils.graphs import example_graph
  from ..None import test_utils
label_desc: Use image node_id 18 for calling a global function with example usage: test_attn_agg_apply() without return types