code: def train(model, device, loader, optimizer, task_type):
      model.train()
  
      for step, batch in enumerate(tqdm(loader, desc="Iteration")):
          batch = batch.to(device)
  
          if batch.x.shape[0] == 1 or batch.batch[-1] == 0:
              pass
          else:
              pred = model(batch)
              optimizer.zero_grad()
              ## ignore nan targets (unlabeled) when computing training loss.
              is_labeled = batch.y == batch.y
              if "classification" in task_type:
                  loss = cls_criterion(
                      pred.to(torch.float32)[is_labeled],
                      batch.y.to(torch.float32)[is_labeled],
                  )
              else:
                  loss = reg_criterion(
                      pred.to(torch.float32)[is_labeled],
                      batch.y.to(torch.float32)[is_labeled],
                  )
              loss.backward()
              optimizer.step()
  
file_path: ogb/examples/graphproppred/mol/main_pyg.py
imports: import torch
  from torch_geometric.loader import DataLoader
  import torch.optim
  import torch.nn.functional
  from gnn import GNN
  from tqdm import tqdm
  import argparse
  import time
  import numpy
  from ogb.graphproppred import PygGraphPropPredDataset, Evaluator
label_desc: Use image node_id 1 for calling a global function with example usage: train(model, device, loader, optimizer, task_type) without return types