code: def test_dataloader(num_workers, device):
      if num_workers > 0 and device != torch.device("cpu"):
          return
  
      x = torch.tensor([[1.0], [1.0], [1.0]])
      edge_index = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]])
      face = torch.tensor([[0], [1], [2]])
      y = 2.0
      z = torch.tensor(0.0)
      name = "data"
  
      data = Data(x=x, edge_index=edge_index, y=y, z=z, name=name).to(
          device
      )
      assert str(data) == (
          "Data(x=[3, 1], edge_index=[2, 4], y=2.0, z=0.0, "
          "name='data')"
      )
      data.face = face
  
      loader = DataLoader(
          [data, data, data, data],
          batch_size=2,
          shuffle=False,
          num_workers=num_workers,
      )
      assert len(loader) == 2
  
      for batch in loader:
          assert batch.x.device == device
          assert batch.edge_index.device == device
          assert batch.z.device == device
          assert batch.num_graphs == len(batch) == 2
          assert batch.batch.tolist() == [0, 0, 0, 1, 1, 1]
          assert batch.ptr.tolist() == [0, 3, 6]
          assert batch.x.tolist() == [[1], [1], [1], [1], [1], [1]]
          assert batch.edge_index.tolist() == [
              [0, 1, 1, 2, 3, 4, 4, 5],
              [1, 0, 2, 1, 4, 3, 5, 4],
          ]
          assert batch.y.tolist() == [2.0, 2.0]
          assert batch.z.tolist() == [0.0, 0.0]
          assert batch.name == ["data", "data"]
          assert batch.face.tolist() == [[0, 3], [1, 4], [2, 5]]
  
          for store in batch.stores:
              assert id(batch) == id(store._parent())
  
      loader = DataLoader(
          [data, data, data, data],
          batch_size=2,
          shuffle=False,
          follow_batch=["edge_index"],
          num_workers=num_workers,
          collate_fn=None,
      )
      assert len(loader) == 2
  
      for batch in loader:
          assert batch.num_graphs == len(batch) == 2
          assert batch.edge_index_batch.tolist() == [
              0,
              0,
              0,
              0,
              1,
              1,
              1,
              1,
          ]
  
file_path: pytorch_geometric/test/loader/test_dataloader.py
imports: import multiprocessing
  import sys
  from collections import namedtuple
  import pytest
  import torch
  from torch_geometric import EdgeIndex
  from torch_geometric.data import Data, HeteroData, OnDiskDataset
  from torch_geometric.loader import DataLoader
  from torch_geometric.testing import get_random_edge_index, get_random_tensor_frame, withCUDA, withPackage
label_desc: Use image node_id 1 for calling a global function with example usage: test_dataloader(num_workers, device) without return types