code: def test_evaluate_link_prediction():
      tf.keras.backend.clear_session()
      edge_ids_test = np.array([[1, 2], [2, 3], [1, 3]])
      edge_labels_test = np.array([1, 1, 0])
  
      graph = example_graph_1(feature_size=4)
  
      # base_model, keras_model, generator, train_gen
      gnn_models = [
          create_graphSAGE_model(graph, link_prediction=True),
          create_HinSAGE_model(graph, link_prediction=True),
      ]
  
      for gnn_model in gnn_models:
          keras_model = gnn_model[1]
          generator = gnn_model[2]
  
          ens = Ensemble(keras_model, n_estimators=2, n_predictions=1)
  
          ens.compile(
              optimizer=Adam(),
              loss=binary_crossentropy,
              weighted_metrics=["acc"],
          )
  
          # Check that passing invalid parameters is handled correctly. We will not check error handling for those
          # parameters that Keras will be responsible for.
          with pytest.raises(ValueError):
              ens.evaluate(
                  generator=generator,
                  test_data=edge_ids_test,
                  test_targets=edge_labels_test,
              )
  
          with pytest.raises(ValueError):
              ens.evaluate(
                  generator=generator,
                  test_data=edge_labels_test,
                  test_targets=None,  # must give test_targets
              )
  
          with pytest.raises(ValueError):
              ens.evaluate(
                  generator=generator.flow(
                      edge_ids_test, edge_labels_test
                  ),
                  test_data=edge_ids_test,
                  test_targets=edge_labels_test,
              )
  
          # We won't train the model instead use the initial random weights to test
          # the evaluate method.
          test_metrics_mean, test_metrics_std = ens.evaluate(
              generator.flow(edge_ids_test, edge_labels_test)
          )
  
          assert len(test_metrics_mean) == len(test_metrics_std)
          assert len(test_metrics_mean.shape) == 1
          assert len(test_metrics_std.shape) == 1
  
          #
          # Repeat for BaggingEnsemble
  
          ens = BaggingEnsemble(
              keras_model, n_estimators=2, n_predictions=1
          )
  
          ens.compile(
              optimizer=Adam(),
              loss=binary_crossentropy,
              weighted_metrics=["acc"],
          )
  
          # Check that passing invalid parameters is handled correctly. We will not check error handling for those
          # parameters that Keras will be responsible for.
          with pytest.raises(ValueError):
              ens.evaluate(
                  generator=generator,
                  test_data=edge_ids_test,
                  test_targets=edge_labels_test,
              )
  
          with pytest.raises(ValueError):
              ens.evaluate(
                  generator=generator,
                  test_data=edge_labels_test,
                  test_targets=None,  # must give test_targets
              )
  
          with pytest.raises(ValueError):
              ens.evaluate(
                  generator=generator.flow(
                      edge_ids_test, edge_labels_test
                  ),
                  test_data=edge_ids_test,
                  test_targets=edge_labels_test,
              )
  
          # We won't train the model instead use the initial random weights to test
          # the evaluate method.
          test_metrics_mean, test_metrics_std = ens.evaluate(
              generator.flow(edge_ids_test, edge_labels_test)
          )
  
          assert len(test_metrics_mean) == len(test_metrics_std)
          assert len(test_metrics_mean.shape) == 1
          assert len(test_metrics_std.shape) == 1
  
imports: import pandas
  import pytest
  import numpy
  import tensorflow
  from stellargraph import StellarGraph
  from stellargraph.layer import GraphSAGE, GCN, GAT, HinSAGE, link_classification, link_regression
  from stellargraph.mapper import GraphSAGENodeGenerator, FullBatchNodeGenerator, HinSAGENodeGenerator, GraphSAGELinkGenerator, HinSAGELinkGenerator
  from stellargraph.ensemble import Ensemble, BaggingEnsemble
  from tensorflow.keras import layers, Model
  from tensorflow.keras.optimizers import Adam
  from tensorflow.keras.losses import categorical_crossentropy, binary_crossentropy
label_desc: Use image node_id 12 for calling a global function with example usage: test_evaluate_link_prediction() without return types