code: def work(self, globalAC):
      global GLOBAL_RUNNING_R, GLOBAL_EP
      total_step = 1
      buffer_s, buffer_a, buffer_r = [], [], []
      while not COORD.should_stop() and GLOBAL_EP < MAX_GLOBAL_EP:
          s = self.env.reset()
          ep_r = 0
          while True:
              # visualize Worker_0 during training
              if (
                  RENDER
                  and self.name == "Worker_0"
                  and total_step % 30 == 0
              ):
                  self.env.render()
              s = s.astype("float32")  # double to float
              a = self.AC.get_action(s)
              s_, r, done, _info = self.env.step(a)
  
              s_ = s_.astype("float32")  # double to float
              # set robot falls reward to -2 instead of -100
              if r == -100:
                  r = -2
  
              ep_r += r
              buffer_s.append(s)
              buffer_a.append(a)
              buffer_r.append(r)
  
              if (
                  total_step % UPDATE_GLOBAL_ITER == 0 or done
              ):  # update global and assign to local net
                  if done:
                      v_s_ = 0  # terminal
                  else:
                      v_s_ = self.AC.critic(s_[np.newaxis, :])[
                          0, 0
                      ]  # reduce dim from 2 to 0
  
                  buffer_v_target = []
  
                  for r in buffer_r[::-1]:  # reverse buffer r
                      v_s_ = r + GAMMA * v_s_
                      buffer_v_target.append(v_s_)
  
                  buffer_v_target.reverse()
  
                  buffer_s = tf.convert_to_tensor(np.vstack(buffer_s))
                  buffer_a = tf.convert_to_tensor(np.vstack(buffer_a))
                  buffer_v_target = tf.convert_to_tensor(
                      np.vstack(buffer_v_target).astype("float32")
                  )
  
                  # update gradients on global network
                  self.AC.update_global(
                      buffer_s, buffer_a, buffer_v_target, globalAC
                  )
                  buffer_s, buffer_a, buffer_r = [], [], []
  
                  # update local network from global network
                  self.AC.pull_global(globalAC)
  
              s = s_
              total_step += 1
              if done:
                  if (
                      len(GLOBAL_RUNNING_R) == 0
                  ):  # record running episode reward
                      GLOBAL_RUNNING_R.append(ep_r)
                  else:  # moving average
                      GLOBAL_RUNNING_R.append(
                          0.95 * GLOBAL_RUNNING_R[-1] + 0.05 * ep_r
                      )
                  print(
                      "Training  | {}, Episode: {}/{}  | Episode Reward: {:.4f}  | Running Time: {:.4f}".format(
                          self.name,
                          GLOBAL_EP,
                          MAX_GLOBAL_EP,
                          ep_r,
                          time.time() - T0,
                      )
                  )
                  GLOBAL_EP += 1
                  break
  
imports: import argparse
  import multiprocessing
  import os
  import threading
  import time
  import gym
  import matplotlib.pyplot
  import numpy
  import tensorflow
  import tensorflow_probability
  import tensorlayer
label_desc: Use image node_id 2 for calling the Worker obj's underlying member method code with example usage: obj.work(globalAC) without return types