code: def train(
      dataloader, model, feature, criterion, optim, log_per_step=100
  ):
      model.train()
  
      batch = 0
      total_loss = 0.0
      total_acc = 0.0
      total_sample = 0
  
      for g, sample_index, index, label in dataloader:
          batch += 1
          num_samples = len(index)
  
          g.tensor()
          sample_index = paddle.to_tensor(sample_index)
          index = paddle.to_tensor(index)
          label = paddle.to_tensor(label)
  
          feat = paddle.gather(feature, sample_index)
          pred = model(g, feat)
          pred = paddle.gather(pred, index)
          loss = criterion(pred, label)
          loss.backward()
          acc = paddle.metric.accuracy(input=pred, label=label, k=1)
          optim.step()
          optim.clear_grad()
  
          total_loss += loss.numpy() * num_samples
          total_acc += acc.numpy() * num_samples
          total_sample += num_samples
  
          if batch % log_per_step == 0:
              log.info(
                  "Batch %s %s-Loss %s %s-Acc %s"
                  % (batch, "train", loss.numpy(), "train", acc.numpy())
              )
  
      return total_loss / total_sample, total_acc / total_sample
  
file_path: PGL/examples/graphsage/cpu_sample_version/train.py
imports: import os
  import argparse
  import time
  from functools import partial
  import numpy
  import tqdm
  import pgl
  import paddle
  from pgl.utils.logger import log
  from pgl.utils.data import Dataloader
  from model import GraphSage
  from dataset import ShardedDataset, batch_fn
label_desc: Use image node_id 1 for calling a global function with example usage: train(dataloader, model, feature, criterion, optim, log_per_step) and returns: unknown,  unknown