class_docstr: Exposes a Python policy as an in-graph TensorFlow policy.
  
  # TODO(kbanoop): This class does not seem to handle batching/unbatching when
  # converting between TF and Py policies.
class_docstr_tok: ["Exposes","a","Python","policy","as","an","in-graph","TensorFlow","policy",".","#","TODO","(","kbanoop",")",":","This","class","does","not","seem","to","handle","batching\/unbatching","when","#","converting","between","TF","and","Py","policies","."]
code: def _action(
      self, time_step, policy_state, seed: Optional[types.Seed] = None
  ):
      if seed is not None:
          raise NotImplementedError(
              "seed is not supported; but saw seed: {}".format(seed)
          )
  
      def _action_fn(*flattened_time_step_and_policy_state):
          (
              packed_py_time_step,
              packed_py_policy_state,
          ) = tf.nest.pack_sequence_as(
              structure=(
                  self._py_policy.time_step_spec,
                  self._py_policy.policy_state_spec,
              ),
              flat_sequence=flattened_time_step_and_policy_state,
          )
          py_action_step = self._py_policy.action(
              time_step=packed_py_time_step,
              policy_state=packed_py_policy_state,
          )
          return tf.nest.flatten(py_action_step)
  
      with tf.name_scope("action"):
          if not self._py_policy_is_batched:
              time_step = nest_utils.unbatch_nested_tensors(time_step)
          flattened_input_tensors = tf.nest.flatten(
              (time_step, policy_state)
          )
  
          flat_action_step = tf.numpy_function(
              _action_fn,
              flattened_input_tensors,
              self._policy_step_dtypes,
              name="action_numpy_function",
          )
          action_step = tf.nest.pack_sequence_as(
              structure=self.policy_step_spec,
              flat_sequence=flat_action_step,
          )
          if not self._py_policy_is_batched:
              action_step = action_step._replace(
                  action=nest_utils.batch_nested_tensors(
                      action_step.action
                  )
              )
          return action_step
  
file_path: agents/tf_agents/policies/tf_py_policy.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Text
  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.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 3 for calling the TFPyPolicy obj's underlying member method code with example usage: obj._action(time_step, policy_state, seed) and returns: tf, action_step