code: def test_ItemSetDict_iteration_seed_nodes():
      # Node IDs.
      user_ids = torch.arange(0, 5)
      item_ids = torch.arange(5, 10)
      ids = {
          "user": gb.ItemSet(user_ids, names="seed_nodes"),
          "item": gb.ItemSet(item_ids, names="seed_nodes"),
      }
      chained_ids = []
      for key, value in ids.items():
          chained_ids += [(key, v) for v in value]
      item_set = gb.ItemSetDict(ids)
      assert item_set.names == ("seed_nodes",)
      # Iterating over ItemSetDict and indexing one by one.
      for i, item in enumerate(item_set):
          assert len(item) == 1
          assert isinstance(item, dict)
          assert chained_ids[i][0] in item
          assert item[chained_ids[i][0]] == chained_ids[i][1]
          assert item_set[i] == item
          assert item_set[i - len(item_set)] == item
      # Indexing all with a slice.
      assert torch.equal(item_set[:]["user"], user_ids)
      assert torch.equal(item_set[:]["item"], item_ids)
      # Indexing partial with a slice.
      partial_data = item_set[:3]
      assert len(list(partial_data.keys())) == 1
      assert torch.equal(partial_data["user"], user_ids[:3])
      partial_data = item_set[7:]
      assert len(list(partial_data.keys())) == 1
      assert torch.equal(partial_data["item"], item_ids[2:])
      partial_data = item_set[3:7]
      assert len(list(partial_data.keys())) == 2
      assert torch.equal(partial_data["user"], user_ids[3:5])
      assert torch.equal(partial_data["item"], item_ids[:2])
  
      # Exception cases.
      with pytest.raises(AssertionError, match="Step must be 1."):
          _ = item_set[::2]
      with pytest.raises(
          AssertionError, match="Start must be smaller than stop."
      ):
          _ = item_set[5:3]
      with pytest.raises(
          AssertionError, match="Start must be smaller than stop."
      ):
          _ = item_set[-1:3]
      with pytest.raises(
          IndexError, match="ItemSetDict index out of range."
      ):
          _ = item_set[20]
      with pytest.raises(
          IndexError, match="ItemSetDict index out of range."
      ):
          _ = item_set[-20]
      with pytest.raises(
          TypeError, match="ItemSetDict indices must be int or slice."
      ):
          _ = item_set[torch.arange(3)]
  
imports: import re
  import dgl
  import pytest
  import torch
  from dgl import graphbolt
  from torch.testing import assert_close
label_desc: Use image node_id 11 for calling a global function with example usage: test_ItemSetDict_iteration_seed_nodes() without return types