code: def train(
      name,
      g,
      model,
      node_embed,
      optimizer,
      train_set,
      valid_set,
      device,
      features,
      num_workers,
      num_epochs,
  ):
      print("Start to train...")
      category = "paper"
  
      num_etype = len(g.num_edges)
      data_loader = create_dataloader(
          name,
          g,
          features,
          train_set,
          device,
          batch_size=1024,
          fanouts=[
              torch.full((num_etype,), 25),
              torch.full((num_etype,), 10),
          ],
          shuffle=True,
          num_workers=num_workers,
      )
  
      # Typically, the best Validation performance is obtained after
      # the 1st or 2nd epoch. This is why the max epoch is set to 3.
      for epoch in range(num_epochs):
          num_train = len(train_set)
          t0 = time.time()
          model.train()
  
          total_loss = 0
  
          for data in tqdm(
              data_loader, desc=f"Training~Epoch {epoch + 1:02d}"
          ):
              # Convert MiniBatch to DGL Blocks and move them to the target
              # device.
              blocks = [block.to(device) for block in data.blocks]
  
              # Fetch the number of seed nodes in the batch.
              num_seeds = blocks[-1].num_dst_nodes(category)
  
              # Extract the node features from embedding layer or raw features.
              node_features = extract_node_features(
                  name, blocks[0], data, node_embed, device
              )
  
              # Reset gradients.
              optimizer.zero_grad()
              # Generate predictions.
              logits = model(blocks, node_features)[category]
  
              y_hat = logits.log_softmax(dim=-1).cpu()
              loss = F.nll_loss(y_hat, data.labels[category].long())
              loss.backward()
              optimizer.step()
  
              total_loss += loss.item() * num_seeds
  
          t1 = time.time()
          loss = total_loss / num_train
  
          # Evaluate the model on the val/test set.
  
          print("Evaluating the model on the validation set.")
          valid_acc = evaluate(
              name,
              g,
              model,
              node_embed,
              device,
              valid_set,
              features,
              num_workers,
          )
          print("Finish evaluating on validation set.")
  
          print(
              f"Epoch: {epoch + 1:02d}, "
              f"Loss: {loss:.4f}, "
              f"Valid accuracy: {100 * valid_acc:.2f}%, "
              f"Time {t1 - t0:.4f}"
          )
  
imports: import argparse
  import itertools
  import sys
  import time
  import dgl
  import dgl.graphbolt
  import dgl.nn
  import psutil
  import torch
  import torch.nn
  import torch.nn.functional
  from dgl.nn import HeteroEmbedding
  from ogb.lsc import MAG240MEvaluator
  from ogb.nodeproppred import Evaluator
  from tqdm import tqdm
label_desc: Use image node_id 7 for calling a global function with example usage: train(name, g, model, node_embed, optimizer, train_set, valid_set, device, features, num_workers, num_epochs) without return types