class_docstr: Program definition for Recurrent Replay Distributed DQN (R2D2).
class_docstr_tok: ["Program","definition","for","Recurrent","Replay","Distributed","DQN","(","R2D2",")","."]
code: def __init__(
      self,
      environment_factory: Callable[[bool], dm_env.Environment],
      network_factory: Callable[[specs.DiscreteArray], snt.RNNCore],
      num_actors: int,
      burn_in_length: int,
      trace_length: int,
      replay_period: int,
      environment_spec: Optional[specs.EnvironmentSpec] = None,
      batch_size: int = 256,
      prefetch_size: int = tf.data.experimental.AUTOTUNE,
      min_replay_size: int = 1000,
      max_replay_size: int = 100_000,
      samples_per_insert: float = 32.0,
      discount: float = 0.99,
      priority_exponent: float = 0.6,
      importance_sampling_exponent: float = 0.2,
      variable_update_period: int = 1000,
      learning_rate: float = 1e-3,
      evaluator_epsilon: float = 0.0,
      target_update_period: int = 100,
      save_logs: bool = False,
  ):
      if environment_spec is None:
          environment_spec = specs.make_environment_spec(
              environment_factory(False)
          )
  
      self._environment_factory = environment_factory
      self._network_factory = network_factory
      self._environment_spec = environment_spec
      self._num_actors = num_actors
      self._batch_size = batch_size
      self._prefetch_size = prefetch_size
      self._min_replay_size = min_replay_size
      self._max_replay_size = max_replay_size
      self._samples_per_insert = samples_per_insert
      self._burn_in_length = burn_in_length
      self._trace_length = trace_length
      self._replay_period = replay_period
      self._discount = discount
      self._target_update_period = target_update_period
      self._variable_update_period = variable_update_period
      self._save_logs = save_logs
      self._priority_exponent = priority_exponent
      self._learning_rate = learning_rate
      self._evaluator_epsilon = evaluator_epsilon
      self._importance_sampling_exponent = importance_sampling_exponent
  
      self._obs_spec = environment_spec.observations
  
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 1 to create a new DistributedR2D2 object  with example: obj = DistributedR2D2(environment_factory, network_factory, num_actors, burn_in_length, trace_length, replay_period, environment_spec, batch_size, prefetch_size, min_replay_size, max_replay_size, samples_per_insert, discount, priority_exponent, importance_sampling_exponent, variable_update_period, learning_rate, evaluator_epsilon, target_update_period, save_logs)