code: def test_ItemSampler_minibatcher():
      # Default minibatcher is used if not specified.
      # Warning message is raised if names are not specified.
      item_set = gb.ItemSet(torch.arange(0, 10))
      item_sampler = gb.ItemSampler(item_set, batch_size=4)
      with pytest.warns(
          UserWarning,
          match=re.escape(
              "Failed to map item list to `MiniBatch` as the names of items are "
              "not provided. Please provide a customized `MiniBatcher`. The "
              "item list is returned as is."
          ),
      ):
          minibatch = next(iter(item_sampler))
          assert not isinstance(minibatch, gb.MiniBatch)
  
      # Default minibatcher is used if not specified.
      # Warning message is raised if unrecognized names are specified.
      item_set = gb.ItemSet(torch.arange(0, 10), names="unknown_name")
      item_sampler = gb.ItemSampler(item_set, batch_size=4)
      with pytest.warns(
          UserWarning,
          match=re.escape(
              "Unknown item name 'unknown_name' is detected and added into "
              "`MiniBatch`. You probably need to provide a customized "
              "`MiniBatcher`."
          ),
      ):
          minibatch = next(iter(item_sampler))
          assert isinstance(minibatch, gb.MiniBatch)
          assert minibatch.unknown_name is not None
  
      # Default minibatcher is used if not specified.
      # `MiniBatch` is returned if expected names are specified.
      item_set = gb.ItemSet(torch.arange(0, 10), names="seed_nodes")
      item_sampler = gb.ItemSampler(item_set, batch_size=4)
      minibatch = next(iter(item_sampler))
      assert isinstance(minibatch, gb.MiniBatch)
      assert minibatch.seed_nodes is not None
      assert len(minibatch.seed_nodes) == 4
  
      # Customized minibatcher is used if specified.
      def minibatcher(batch, names):
          return gb.MiniBatch(seed_nodes=batch)
  
      item_sampler = gb.ItemSampler(
          item_set, batch_size=4, minibatcher=minibatcher
      )
      minibatch = next(iter(item_sampler))
      assert isinstance(minibatch, gb.MiniBatch)
      assert minibatch.seed_nodes is not None
      assert len(minibatch.seed_nodes) == 4
  
imports: import os
  import re
  from sys import platform
  import dgl
  import pytest
  import torch
  import torch.distributed
  import torch.multiprocessing
  from dgl import graphbolt
  from torch.testing import assert_close
label_desc: Use image node_id 1 for calling a global function with example usage: test_ItemSampler_minibatcher() and returns: gb