code: def inference(model, loader, save_dir):
      model.eval()
      save_file = os.path.join(save_dir, "embedding.txt")
      cc = 0
      with open(save_file, "w") as writer:
          for step, feed_dict in enumerate(loader()):
              feed_dict = data2tensor(feed_dict)
              pred = model(feed_dict)
              node_ids, node_embed = model.get_embedding()
              for nid, vec in zip(
                  node_ids.numpy().reshape(-1), node_embed.numpy()
              ):
                  str_vec = " ".join(map(str, vec))
                  writer.write("%s\t%s\n" % (nid, str_vec))
                  cc += 1
  
                  if cc % 10000 == 0:
                      log.info("%s nodes have been processed" % (cc))
  
      log.info("total %s nodes have been processed" % cc)
      log.info("node representations are saved in %s" % save_file)
      model.train()
  
file_path: PGL/apps/Graph4Rec/env_run/src/infer.py
imports: import os
  import sys
  import time
  import tqdm
  import yaml
  import argparse
  import numpy
  import pgl
  from pgl.utils.logger import log
  from pgl.utils.data import Dataloader, StreamDataset
  import paddle
  import paddle.nn
  from paddle.optimizer import Adam
  from utils.config import prepare_config
  from utils.logger import log_to_file
  import models
  import datasets.dataset
label_desc: Use image node_id 2 for calling a global function with example usage: inference(model, loader, save_dir) without return types