class_docstr: Recurrent exponentially Q-weighted policy.
class_docstr_tok: ["Recurrent","exponentially","Q-weighted","policy","."]
docstr: Computes a forward step for a single element.
  
  The observation and state are packed together in order to use
  `tf.vectorized_map` to handle batches of observations.
  See this module's __call__() function.
  
  Args:
    observation_and_state: the observation and state packed in a tuple.
  
  Returns:
    The selected action and the corresponding state.
docstr_tok: ["Computes","a","forward","step","for","a","single","element",".","The","observation","and","state","are","packed","together","in","order","to","use","`","tf.vectorized_map","`","to","handle","batches","of","observations",".","See","this","module","'s","__call__","(",")","function",".","Args",":","observation_and_state",":","the","observation","and","state","packed","in","a","tuple",".","Returns",":","The","selected","action","and","the","corresponding","state","."]
code: def _call(
      self,
      observation_and_state: Tuple[
          types.NestedTensor, PolicyCriticRNNState
      ],
  ) -> Tuple[types.NestedTensor, PolicyCriticRNNState]:
      """Computes a forward step for a single element.
  
      The observation and state are packed together in order to use
      `tf.vectorized_map` to handle batches of observations.
      See this module's __call__() function.
  
      Args:
        observation_and_state: the observation and state packed in a tuple.
  
      Returns:
        The selected action and the corresponding state.
      """
      observation, prev_state = observation_and_state
  
      # Tile input observations and states to allow multiple policy predictions.
      tiled_observation, tiled_prev_state = utils.tile_nested(
          (observation, prev_state), self._num_action_samples
      )
      actions, policy_states = self._policy_network(
          tiled_observation, tiled_prev_state.policy
      )
  
      # Evaluate multiple critic predictions with the sampled actions.
      value_distribution, critic_states = self._critic_network(
          tiled_observation, actions, tiled_prev_state.critic
      )
      value_estimate = value_distribution.mean()
  
      # Resample a single action of the sampled actions according to logits given
      # by the tempered Q-values.
      selected_action_idx = tfp.distributions.Categorical(
          probs=tf.nn.softmax(value_estimate / self._temperature_beta)
      ).sample()
      selected_action = actions[selected_action_idx]
  
      # Select and return the RNN state that corresponds to the selected action.
      states = PolicyCriticRNNState(
          policy=policy_states, critic=critic_states
      )
      selected_state = tree.map_structure(
          lambda x: x[selected_action_idx], states
      )
  
      return selected_action, selected_state
  
imports: import functools
  from typing import NamedTuple, Optional, Sequence, Tuple
  from absl import logging
  from acme import types
  from acme.tf import savers
  from acme.tf import utils
  from acme.tf.networks import base
  import sonnet
  import tensorflow
  import tensorflow_probability
  import tree
label_desc: Use image node_id 3 for calling the RecurrentExpQWeightedPolicy obj's underlying member method code with example usage: obj._call(observation_and_state) and returns: selected_action,  selected_state