code: def test_edge_dataloader_excludes(
      exclude, always_exclude_flag, batch_size, sampler
  ):
      if exclude == "reverse_types":
          (
              g,
              reverse_etypes,
              always_exclude,
              seed_edges,
          ) = _create_heterogeneous()
      else:
          (
              g,
              reverse_eids,
              always_exclude,
              seed_edges,
          ) = _create_homogeneous()
      g = g.to(F.ctx())
      if not always_exclude_flag:
          always_exclude = None
  
      kwargs = {}
      kwargs["exclude"] = (
          partial(_find_edges_to_exclude, g, exclude, always_exclude)
          if always_exclude_flag
          else exclude
      )
      kwargs["reverse_eids"] = (
          reverse_eids if exclude == "reverse_id" else None
      )
      kwargs["reverse_etypes"] = (
          reverse_etypes if exclude == "reverse_types" else None
      )
      sampler = dgl.dataloading.as_edge_prediction_sampler(
          sampler, **kwargs
      )
  
      dataloader = dgl.dataloading.DataLoader(
          g,
          seed_edges,
          sampler,
          batch_size=batch_size,
          device=F.ctx(),
          use_prefetch_thread=False,
      )
      for i, (input_nodes, 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, exclude, always_exclude, pair_eids
          )
          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
  
imports: import os
  import unittest
  from collections.abc import Iterator, Mapping
  from functools import partial
  import backend
  import dgl
  import dgl.ops
  import numpy
  import pytest
  import torch
  import torch.distributed
  import torch.multiprocessing
  from utils import parametrize_idtype
label_desc: Use image node_id 16 for calling a global function with example usage: test_edge_dataloader_excludes(exclude, always_exclude_flag, batch_size, sampler) without return types