class_docstr: Utility class for distributed infer of PaddlePaddle.
class_docstr_tok: ["Utility","class","for","distributed","infer","of","PaddlePaddle","."]
code: def init_distributed_infer_env(
      self, exe, loss, role_maker=None, dirname=None
  ):
      import paddle.distributed.fleet as fleet
  
      if fleet.fleet._runtime_handle is None:
          fleet.init(role_maker=role_maker)
  
          #  fake_optimizer = paddle.optimizer.SGD()
          fake_optimizer = paddle.optimizer.Adam()
          strategy = fleet.DistributedStrategy()
          strategy.a_sync = True
          optimizer = fleet.distributed_optimizer(
              fake_optimizer, strategy=strategy
          )
          optimizer.minimize(
              loss, startup_program=self.origin_startup_program
          )
  
          if fleet.is_server():
              fleet.init_server(dirname=dirname)
              fleet.run_server()
          else:
              exe.run(paddle.static.default_startup_program())
              fleet.init_worker()
              self._init_dense_params(exe, dirname)
          global_startup_program = (
              paddle.static.default_startup_program()
          )
          global_startup_program = self.origin_startup_program
          global_main_program = paddle.static.default_main_program()
          global_main_program = self.origin_main_program
  
file_path: PGL/apps/Graph4Rec/env_run/src/utils/ps_util.py
imports: import numpy
  import os
  import paddle
  import warnings
label_desc: Use image node_id 2 for calling the DistributedInfer obj's underlying member method code with example usage: obj.init_distributed_infer_env(exe, loss, role_maker, dirname) without return types