code: def train(
      device, g, dataset, model, num_classes, use_uva, fused_sampling
  ):
      # Create sampler & dataloader.
      train_idx = dataset.train_idx.to(
          g.device if not use_uva else device
      )
      val_idx = dataset.val_idx.to(g.device if not use_uva else device)
      #####################################################################
      # (HIGHLIGHT) Instantiate a NeighborSampler object for efficient
      # training of Graph Neural Networks (GNNs) on large-scale graphs.
      #
      # The argument [10, 10, 10] sets the number of neighbors (fanout)
      # to be sampled at each layer. Here, we have three layers, and
      # 10 neighbors will be randomly selected for each node at each
      # layer.
      #
      # The 'prefetch_node_feats' and 'prefetch_labels' parameters
      # specify the node features and labels that need to be pre-fetched
      # during sampling. More details about `prefetch` can be found in the
      # `SAGE.inference` function.
      #####################################################################
      sampler = NeighborSampler(
          [10, 10, 10],  # fanout for [layer-0, layer-1, layer-2]
          prefetch_node_feats=["feat"],
          prefetch_labels=["label"],
          fused=fused_sampling,
      )
  
      train_dataloader = DataLoader(
          g,
          train_idx,
          sampler,
          device=device,
          batch_size=1024,
          shuffle=True,
          drop_last=False,
          # If `g` is on gpu or `use_uva` is True, `num_workers` must be zero,
          # otherwise it will cause error.
          num_workers=0,
          use_uva=use_uva,
      )
  
      val_dataloader = DataLoader(
          g,
          val_idx,
          sampler,
          device=device,
          batch_size=1024,
          # No need to shuffle for validation.
          shuffle=False,
          drop_last=False,
          num_workers=0,
          use_uva=use_uva,
      )
  
      opt = torch.optim.Adam(
          model.parameters(), lr=1e-3, weight_decay=5e-4
      )
  
      for epoch in range(10):
          t0 = time.time()
          model.train()
          total_loss = 0
          # A block is a graph consisting of two sets of nodes: the
          # source nodes and destination nodes. The source and destination
          # nodes can have multiple node types. All the edges connect from
          # source nodes to destination nodes.
          # For more details: https://discuss.dgl.ai/t/what-is-the-block/2932.
          for it, (input_nodes, output_nodes, blocks) in enumerate(
              train_dataloader
          ):
              # The input features from the source nodes in the first layer's
              # computation graph.
              x = blocks[0].srcdata["feat"]
  
              # The ground truth labels from the destination nodes
              # in the last layer's computation graph.
              y = blocks[-1].dstdata["label"]
  
              y_hat = model(blocks, x)
              loss = F.cross_entropy(y_hat, y)
              opt.zero_grad()
              loss.backward()
              opt.step()
              total_loss += loss.item()
          t1 = time.time()
          acc = evaluate(model, g, val_dataloader, num_classes)
          print(
              f"Epoch {epoch:05d} | Loss {total_loss / (it + 1):.4f} | "
              f"Accuracy {acc.item():.4f} | Time {t1 - t0:.4f}"
          )
  
file_path: dgl/examples/sampling/node_classification.py
imports: import argparse
  import time
  import dgl
  import dgl.nn
  import torch
  import torch.nn
  import torch.nn.functional
  import torchmetrics.functional
  import tqdm
  from dgl.data import AsNodePredDataset
  from dgl.dataloading import DataLoader, MultiLayerFullNeighborSampler, NeighborSampler
  from ogb.nodeproppred import DglNodePropPredDataset
label_desc: Use image node_id 3 for calling a global function with example usage: train(device, g, dataset, model, num_classes, use_uva, fused_sampling) without return types