code: def test_link_prediction(petersen_graph, shuffle):
      num_examples = 10
      edge_ids = np.random.choice(
          petersen_graph.nodes(), size=(num_examples, 2)
      )
      edge_labels = np.random.choice([0, 1], size=num_examples)
      assert_reproducible(
          lambda: gs_link_prediction(
              petersen_graph,
              edge_ids,
              edge_labels,
              [2, 2],
              tf.optimizers.Adam(1e-3),
              shuffle=shuffle,
          )
      )
  
imports: import numpy
  import pytest
  import random
  import tensorflow
  from stellargraph.data.unsupervised_sampler import UnsupervisedSampler
  from stellargraph.mapper.sampled_node_generators import GraphSAGENodeGenerator
  from stellargraph.mapper.sampled_link_generators import GraphSAGELinkGenerator
  from stellargraph.layer.graphsage import GraphSAGE
  from stellargraph.layer.link_inference import link_classification
  from stellargraph.random import set_seed
  from ..test_utils import flaky_xfail_mark
  from ..test_utils.graphs import petersen_graph
  from .fixtures import assert_reproducible
  from ..None import require_gpu
label_desc: Use image node_id 9 for calling a global function with example usage: test_link_prediction(petersen_graph, shuffle) without return types