code: def worker_task(ps, worker_index, batch_size=50):
      # Download MNIST.
      print("Worker " + str(worker_index))
      mnist = model.download_mnist_retry(seed=worker_index)
  
      # Initialize the model.
      net = model.SimpleCNN()
      keys = net.get_weights()[0]
  
      while True:
          # Get the current weights from the parameter server.
          weights = ray.get(ps.pull.remote(keys))
          net.set_weights(keys, weights)
          # Compute an update and push it to the parameter server.
          xs, ys = mnist.train.next_batch(batch_size)
          gradients = net.compute_update(xs, ys)
          ps.push.remote(keys, gradients)
  
file_path: analytics-zoo/pyzoo/zoo/examples/ray_on_spark/parameter_server/async_parameter_server.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import os
  import time
  from zoo.examples.ray_on_spark.parameter_server import model
  import ray
  from zoo.orca import init_orca_context, stop_orca_context
  from zoo.orca import OrcaContext
label_desc: Use image node_id 1 for calling a global function with example usage: worker_task(ps, worker_index, batch_size) without return types