code: def test_NeighborSampler_invoke(labor):
      graph = gb_test_utils.rand_csc_graph(
          20, 0.15, bidirection_edge=True
      ).to(F.ctx())
      itemset = gb.ItemSet(torch.arange(10), names="seed_nodes")
      item_sampler = gb.ItemSampler(itemset, batch_size=2).copy_to(
          F.ctx()
      )
      num_layer = 2
      fanouts = [torch.LongTensor([2]) for _ in range(num_layer)]
  
      # Invoke via class constructor.
      Sampler = gb.LayerNeighborSampler if labor else gb.NeighborSampler
      datapipe = Sampler(item_sampler, graph, fanouts)
      assert len(list(datapipe)) == 5
  
      # Invokde via functional form.
      if labor:
          datapipe = item_sampler.sample_layer_neighbor(graph, fanouts)
      else:
          datapipe = item_sampler.sample_neighbor(graph, fanouts)
      assert len(list(datapipe)) == 5
  
imports: import unittest
  from enum import Enum
  from functools import partial
  import backend
  import dgl
  import dgl.graphbolt
  import pytest
  import torch
  from torchdata.datapipes.iter import Mapper
  from .None import gb_test_utils
label_desc: Use image node_id 4 for calling a global function with example usage: test_NeighborSampler_invoke(labor) without return types