class_docstr: Exposes a Python policy as wrapper over a TF Policy.
class_docstr_tok: ["Exposes","a","Python","policy","as","wrapper","over","a","TF","Policy","."]
code: def _action(
      self, time_step, policy_state, seed: Optional[types.Seed] = None
  ):
      if seed is not None:
          raise ValueError(
              "`seed` is passed to the class as an argument."
          )
      if not self._built:
          self._build_from_time_step(time_step)
  
      batch_size = None
      if time_step.step_type.shape:
          batch_size = time_step.step_type.shape[0]
      if self._batch_size != batch_size:
          raise ValueError(
              "The batch size of time_step is different from the batch size "
              "provided previously. Expected {}, but saw {}.".format(
                  self._batch_size, batch_size
              )
          )
  
      if not self._batched:
          # Since policy_state is given in a batched form from the policy and we
          # simply have to send it back we do not need to worry about it. Only
          # update time_step.
          time_step = nest_utils.batch_nested_array(time_step)
  
      nest_utils.assert_same_structure(self._time_step, time_step)
      feed_dict = {self._time_step: time_step}
      if policy_state is not None:
          # Flatten policy_state to handle specs that are not hashable due to lists.
          for state_ph, state in zip(
              tf.nest.flatten(self._policy_state),
              tf.nest.flatten(policy_state),
          ):
              feed_dict[state_ph] = state
  
      action_step = self.session.run(self._action_step, feed_dict)
      action, state, info = action_step
  
      if not self._batched:
          action, info = nest_utils.unbatch_nested_array([action, info])
  
      return policy_step.PolicyStep(action, state, info)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Text
  from absl import logging
  import tensorflow
  from tf_agents.policies import py_policy
  from tf_agents.policies import tf_policy
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
  from tf_agents.utils import session_utils
label_desc: Use image node_id 8 for calling the PyTFPolicy obj's underlying member method code with example usage: obj._action(time_step, policy_state, seed) and returns: policy_step