class_docstr: Program definition for MPO.
class_docstr_tok: ["Program","definition","for","MPO","."]
docstr: The actor process.
docstr_tok: ["The","actor","process","."]
code: def actor(
      self,
      replay: reverb.Client,
      variable_source: acme.VariableSource,
      counter: counting.Counter,
  ) -> acme.EnvironmentLoop:
      """The actor process."""
  
      action_spec = self._environment_spec.actions
      observation_spec = self._environment_spec.observations
  
      # Create environment and target networks to act with.
      environment = self._environment_factory(False)
      agent_networks = self._network_factory(action_spec)
  
      # Create a stochastic behavior policy.
      behavior_modules = [
          agent_networks.get("observation", tf.identity),
          agent_networks.get("policy"),
          networks.StochasticSamplingHead(),
      ]
      behavior_network = snt.Sequential(behavior_modules)
  
      # Ensure network variables are created.
      tf2_utils.create_variables(behavior_network, [observation_spec])
      policy_variables = {"policy": behavior_network.variables}
  
      # Create the variable client responsible for keeping the actor up-to-date.
      variable_client = tf2_variable_utils.VariableClient(
          variable_source,
          policy_variables,
          update_period=self._variable_update_period,
      )
  
      # Make sure not to use a random policy after checkpoint restoration by
      # assigning variables before running the environment loop.
      variable_client.update_and_wait()
  
      # Component to add things into replay.
      adder = adders.NStepTransitionAdder(
          client=replay,
          n_step=self._n_step,
          discount=self._additional_discount,
      )
  
      # Create the agent.
      actor = actors.FeedForwardActor(
          policy_network=behavior_network,
          adder=adder,
          variable_client=variable_client,
      )
  
      # Create logger and counter; actors will not spam bigtable.
      counter = counting.Counter(counter, "actor")
      logger = loggers.make_default_logger(
          "actor",
          save_data=False,
          time_delta=self._log_every,
          steps_key="actor_steps",
      )
  
      # Create the run loop and return it.
      return acme.EnvironmentLoop(environment, actor, counter, logger)
  
imports: from typing import Callable, Dict, 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.mpo import learning
  from acme.tf import networks
  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 reverb
  import sonnet
  import tensorflow
label_desc: Use image node_id 6 for calling the DistributedMPO obj's underlying member method code with example usage: obj.actor(replay, variable_source, counter) and returns: acme