code: def test_UniformNegativeSampler_invoke():
      # Instantiate graph and required datapipes.
      graph = gb_test_utils.rand_csc_graph(
          100, 0.05, bidirection_edge=True
      )
      num_seeds = 30
      item_set = gb.ItemSet(
          torch.arange(0, 2 * num_seeds).reshape(-1, 2),
          names="node_pairs",
      )
      batch_size = 10
      item_sampler = gb.ItemSampler(item_set, batch_size=batch_size)
      negative_ratio = 2
  
      # Verify iteration over UniformNegativeSampler.
      def _verify(negative_sampler):
          for data in negative_sampler:
              # Assertation
              assert data.negative_srcs is None
              assert data.negative_dsts.size(0) == batch_size
              assert data.negative_dsts.size(1) == negative_ratio
  
      # Invoke UniformNegativeSampler via class constructor.
      negative_sampler = gb.UniformNegativeSampler(
          item_sampler,
          graph,
          negative_ratio,
      )
      _verify(negative_sampler)
  
      # Invoke UniformNegativeSampler via functional form.
      negative_sampler = item_sampler.sample_uniform_negative(
          graph,
          negative_ratio,
      )
      _verify(negative_sampler)
  
file_path: dgl/tests/python/pytorch/graphbolt/impl/test_negative_sampler.py
imports: import dgl.graphbolt
  import pytest
  import torch
  from ..None import gb_test_utils
label_desc: Use image node_id 2 for calling a global function with example usage: test_UniformNegativeSampler_invoke() without return types