code: def main(args):
      log.info("start")
  
      worker_num = int(os.getenv("PADDLE_TRAINERS_NUM", "0"))
      num_devices = int(os.getenv("CPU_NUM", 10))
  
      model = Metapath2vecModel(config=args)
      pyreader = model.pyreader
      loss = model.forward()
  
      # init fleet
      role = role_maker.PaddleCloudRoleMaker()
      fleet.init(role)
  
      train_steps = math.ceil(
          args.num_nodes
          * args.epochs
          / args.batch_size
          / num_devices
          / worker_num
      )
      log.info("Train step: %s" % train_steps)
  
      real_batch_size = args.batch_size * args.walk_len * args.win_size
      if args.optimizer == "sgd":
          args.lr *= real_batch_size
      optimization(args.lr, loss, train_steps, args.optimizer)
  
      # init and run server or worker
      if fleet.is_server():
          fleet.init_server(args.warm_start_from_dir)
          fleet.run_server()
  
      if fleet.is_worker():
          log.info("start init worker done")
          fleet.init_worker()
          # just the worker, load the sample
          log.info("init worker done")
  
          exe = F.Executor(F.CPUPlace())
          exe.run(fleet.startup_program)
          log.info("Startup done")
  
          dataset = m2vGraph(args)
          log.info("Build graph done.")
  
          data_generator = multiprocess_data_generator(args, dataset)
  
          cur_time = time.time()
          for idx, _ in enumerate(data_generator()):
              log.info("iter %s: %s s" % (idx, time.time() - cur_time))
              cur_time = time.time()
              if idx == 100:
                  break
  
          pyreader.decorate_tensor_provider(data_generator)
          pyreader.start()
  
          compiled_prog = build_complied_prog(fleet.main_program, loss)
          train_prog(
              exe, compiled_prog, loss, pyreader, args, train_steps
          )
  
file_path: PGL/legacy/examples/distribute_metapath2vec/cluster_train.py
imports: import argparse
  import time
  import os
  import math
  import numpy
  import paddle.fluid
  import paddle.fluid.layers
  from paddle.fluid.incubate.fleet.parameter_server.distribute_transpiler import fleet
  import paddle.fluid.incubate.fleet.base.role_maker
  from paddle.fluid.incubate.fleet.parameter_server.distribute_transpiler import StrategyFactory
  from pgl.utils.logger import log
  from model import Metapath2vecModel
  from graph import m2vGraph
  from utils import load_config
  from walker import multiprocess_data_generator
label_desc: Use image node_id 4 for calling a global function with example usage: main(args) without return types