class_docstr: Program definition for Recurrent Replay Distributed DQN (R2D2).
class_docstr_tok: ["Program","definition","for","Recurrent","Replay","Distributed","DQN","(","R2D2",")","."]
docstr: Build the distributed agent topology.
docstr_tok: ["Build","the","distributed","agent","topology","."]
code: def build(self, name="r2d2"):
      """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))
  
      with program.group("learner"):
          learner = program.add_node(
              lp.CourierNode(self.learner, replay, counter)
          )
  
      with program.group("cacher"):
          cacher = program.add_node(
              lp.CacherNode(
                  learner, refresh_interval_ms=2000, stale_after_ms=4000
              )
          )
  
      with program.group("evaluator"):
          program.add_node(
              lp.CourierNode(self.evaluator, cacher, 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("actor"):
          for epsilon in epsilons:
              program.add_node(
                  lp.CourierNode(
                      self.actor, replay, cacher, counter, epsilon
                  )
              )
  
      return program
  
imports: import copy
  from typing import Callable, List, 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.r2d2 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
  import dm_env
  import launchpad
  import numpy
  import reverb
  import sonnet
  import tensorflow
  import trfl
label_desc: Use image node_id 7 for calling the DistributedR2D2 obj's underlying member method code with example usage: obj.build(name) and returns: program