class_docstr: PS StrategyBuilder.
  
  Generates a Strategy that synchronizes every variable
  using Parameter Servers. Each variable is only assigned
  to one Parameter Server.
class_docstr_tok: ["PS","StrategyBuilder",".","Generates","a","Strategy","that","synchronizes","every","variable","using","Parameter","Servers",".","Each","variable","is","only","assigned","to","one","Parameter","Server","."]
docstr: Build PS strategy.
docstr_tok: ["Build","PS","strategy","."]
code: def build(self, graph_item, resource_spec):
      """Build PS strategy."""
      expr = Strategy()
  
      # get each variable, generate variable synchronizer config
      expr.graph_config.replicas.extend(
          [k for k, v in resource_spec.gpu_devices]
      )
      for k, v in resource_spec.node_cpu_devices.items():
          if k not in resource_spec.node_gpu_devices:
              expr.graph_config.replicas.extend(v)
  
      # find all variables
      variables = graph_item.trainable_var_op_to_var.values()
      reduction_device_name = [k for k, _ in resource_spec.cpu_devices][
          0
      ]
  
      # Mark each variable to be synchronized with a Parameter Server
      node_config = [
          self._gen_ps_node_config(
              var.name,
              reduction_device_name,
              self._local_proxy_variable,
              self._sync,
              self._staleness,
          )
          for var in variables
      ]
      expr.node_config.extend(node_config)
      return expr
  
imports: from autodist.strategy.base import Strategy, StrategyBuilder
  from autodist.proto import strategy_pb2
label_desc: Use image node_id 2 for calling the PS obj's underlying member method code with example usage: obj.build(graph_item, resource_spec) and returns: expr