code: def train(model, data_loader, optim, log_per_step=10):
      model.train()
      total_loss = 0.0
      total_sample = 0
  
      for batch, (src, dsts) in enumerate(data_loader):
          num_samples = len(src)
          src = paddle.to_tensor(src)
          dsts = paddle.to_tensor(dsts)
          loss = model(src, dsts)
          loss.backward()
          optim.step()
          optim.clear_grad()
  
          total_loss += float(loss) * num_samples
          total_sample += num_samples
  
          if batch % log_per_step == 0:
              log.info(
                  "Batch %s %s-Loss %.6f"
                  % (batch, "train", float(loss))
              )
  
      return total_loss / total_sample
  
file_path: PGL/examples/deepwalk/train.py
imports: import time
  import argparse
  import pgl
  import paddle
  import paddle.nn
  from pgl.utils.logger import log
  import numpy
  import yaml
  from easydict import EasyDict
  import tqdm
  from paddle.optimizer import Adam
  from pgl.utils.data import Dataloader
  from paddle.io import get_worker_info
  from model import SkipGramModel
  from dataset import ShardedDataset
  from dataset import BatchRandWalk
label_desc: Use image node_id 3 for calling a global function with example usage: train(model, data_loader, optim, log_per_step) and returns: unknown