code: def test_spot_target_excludes(degree_threshold, batch_size):
      g, reverse_eids, seed_edges = _create_homogeneous()
      sampler = dgl.dataloading.MultiLayerFullNeighborSampler(1)
      low_degree_excluder = dgl.dataloading.SpotTarget(
          g,
          exclude="reverse_id",
          degree_threshold=degree_threshold,
          reverse_eids=reverse_eids,
      )
      sampler = dgl.dataloading.as_edge_prediction_sampler(
          sampler,
          exclude=low_degree_excluder,
          negative_sampler=dgl.dataloading.negative_sampler.Uniform(1),
      )
      dataloader = dgl.dataloading.DataLoader(
          g, seed_edges, sampler, batch_size=batch_size
      )
  
      for i, (
          input_nodes,
          pair_graph,
          neg_pair_graph,
          blocks,
      ) in enumerate(dataloader):
          if isinstance(blocks, list):
              subg = blocks[0]
          else:
              subg = blocks
          pair_eids = pair_graph.edata[dgl.EID]
          block_eids = subg.edata[dgl.EID]
          edges_to_exclude = _find_edges_to_exclude(
              g, pair_eids, degree_threshold
          )
          if edges_to_exclude is None:
              continue
          edges_to_exclude = dgl.utils.recursive_apply(
              edges_to_exclude, lambda x: x.cpu().numpy()
          )
          block_eids = dgl.utils.recursive_apply(
              block_eids, lambda x: x.cpu().numpy()
          )
  
          if isinstance(edges_to_exclude, Mapping):
              for k in edges_to_exclude.keys():
                  assert not np.isin(
                      edges_to_exclude[k], block_eids[k]
                  ).any()
          else:
              assert not np.isin(edges_to_exclude, block_eids).any()
  
          if i == 10:
              break
  
file_path: dgl/tests/python/pytorch/dataloading/test_spot_target.py
imports: from collections.abc import Mapping
  import dgl
  import numpy
  import pytest
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: test_spot_target_excludes(degree_threshold, batch_size) without return types