class_docstr: Distributed DQN agent.
class_docstr_tok: ["Distributed","DQN","agent","."]
docstr: Build the distributed agent topology.
docstr_tok: ["Build","the","distributed","agent","topology","."]
code: def build(self, name="dqn"):
      """Build the distributed agent topology."""
      program = lp.Program(name=name)
  
      with program.group("replay"):
          replay = program.add_node(lp.ReverbNode(self.replay))
  
      with program.group("counter"):
          counter = program.add_node(lp.CourierNode(self.counter))
  
          if self._max_actor_steps:
              program.add_node(
                  lp.CourierNode(
                      self.coordinator, counter, self._max_actor_steps
                  )
              )
  
      with program.group("learner"):
          learner = program.add_node(
              lp.CourierNode(self.learner, replay, counter)
          )
  
      with program.group("evaluator"):
          program.add_node(
              lp.CourierNode(self.evaluator, learner, counter)
          )
  
      # Generate an epsilon for each actor.
      epsilons = np.flip(
          np.logspace(1, 8, self._num_actors, base=0.4), axis=0
      )
  
      with program.group("cacher"):
          # Create a set of learner caches.
          sources = []
          for _ in range(self._num_caches):
              cacher = program.add_node(
                  lp.CacherNode(
                      learner,
                      refresh_interval_ms=2000,
                      stale_after_ms=4000,
                  )
              )
              sources.append(cacher)
  
      with program.group("actor"):
          # Add actors which pull round-robin from our variable sources.
          for actor_id, epsilon in enumerate(epsilons):
              source = sources[actor_id % len(sources)]
              program.add_node(
                  lp.CourierNode(
                      self.actor, replay, source, counter, epsilon
                  )
              )
  
      return program
  
imports: import copy
  from typing import Callable, Optional
  import acme
  from acme import datasets
  from acme import specs
  from acme.adders import reverb
  from acme.agents.tf import actors
  from acme.agents.tf.dqn import learning
  from acme.tf import savers
  from acme.tf import utils
  from acme.tf import variable_utils
  from acme.utils import counting
  from acme.utils import loggers
  from acme.utils import lp_utils
  import dm_env
  import launchpad
  import numpy
  import reverb
  import sonnet
  import trfl
label_desc: Use image node_id 8 for calling the DistributedDQN obj's underlying member method code with example usage: obj.build(name) and returns: program