class_docstr: AllReduce StrategyBuilder.
  
  This StrategyBuilder generates a strategy that synchronizes every dense variable using AllReduce.
  It will sequentially merge collective ops into a single collective group based on chunk_size.
  
  This strategy does not support synchronizing sparse updates with >1 nodes due to the TF AllGather bug.
class_docstr_tok: ["AllReduce","StrategyBuilder",".","This","StrategyBuilder","generates","a","strategy","that","synchronizes","every","dense","variable","using","AllReduce",".","It","will","sequentially","merge","collective","ops","into","a","single","collective","group","based","on","chunk_size",".","This","strategy","does","not","support","synchronizing","sparse","updates","with",">","1","nodes","due","to","the","TF","AllGather","bug","."]
docstr: Generate the strategy.
docstr_tok: ["Generate","the","strategy","."]
code: def build(self, graph_item, resource_spec):
      """Generate the 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()
  
      # Mark each variable to be synchronized with allreduce
      for i, var in enumerate(variables):
          group_id = i // self.chunk_size
          node_config = self._gen_all_reduce_node_config(
              var.name,
              group=group_id,
              all_reduce_spec=self.all_reduce_spec,
              compressor=self.compressor,
          )
          expr.node_config.append(node_config)
  
      return expr
  
imports: from autodist.strategy.base import Strategy, StrategyBuilder
  from autodist.proto import strategy_pb2, synchronizers_pb2
label_desc: Use image node_id 2 for calling the AllReduce obj's underlying member method code with example usage: obj.build(graph_item, resource_spec) and returns: expr