class_docstr: A recurrent actor.
class_docstr_tok: ["A","recurrent","actor","."]
code: def select_action(
      self, observation: types.NestedArray
  ) -> types.NestedArray:
      # Add a dummy batch dimension and as a side effect convert numpy to TF.
      batched_obs = tf2_utils.add_batch_dim(observation)
  
      if self._state is None:
          self._state = self._network.initial_state(1)
  
      # Forward.
      (logits, _), new_state = self._policy(batched_obs, self._state)
  
      self._prev_logits = logits
      self._prev_state = self._state
      self._state = new_state
  
      action = tfd.Categorical(logits).sample()
      action = tf2_utils.to_numpy_squeeze(action)
  
      return action
  
file_path: acme/acme/agents/tf/impala/acting.py
imports: from typing import Optional
  from acme import adders
  from acme import core
  from acme import types
  from acme.tf import utils
  from acme.tf import variable_utils
  import dm_env
  import sonnet
  import tensorflow
  import tensorflow_probability
label_desc: Use image node_id 2 for calling the IMPALAActor obj's underlying member method code with example usage: obj.select_action(observation) and returns: action