class_docstr: Abstract base class for Python Policies.
  
  The `action(time_step, policy_state)` method returns a PolicyStep named tuple
  containing the following nested arrays:
    `action`: The action to be applied on the environment.
    `state`: The state of the policy (E.g. RNN state) to be fed into the next
      call to action.
    `info`: Optional side information such as action log probabilities.
  
  For stateful policies, e.g. those containing RNNs, an initial policy state can
  be obtained through a call to `get_initial_state()`.
  
  Example of simple use in Python:
  
    py_env = PyEnvironment()
    policy = PyPolicy()
  
    time_step = py_env.reset()
    policy_state = policy.get_initial_state()
  
    acc_reward = 0
    while not time_step.is_last():
      action_step = policy.action(time_step, policy_state)
      policy_state = action_step.state
      time_step = py_env.step(action_step.action)
      acc_reward += time_step.reward
class_docstr_tok: ["Abstract","base","class","for","Python","Policies",".","The","`","action","(","time_step",",","policy_state",")","`","method","returns","a","PolicyStep","named","tuple","containing","the","following","nested","arrays",":","`","action","`",":","The","action","to","be","applied","on","the","environment",".","`","state","`",":","The","state","of","the","policy","(","E.g",".","RNN","state",")","to","be","fed","into","the","next","call","to","action",".","`","info","`",":","Optional","side","information","such","as","action","log","probabilities",".","For","stateful","policies",",","e.g",".","those","containing","RNNs",",","an","initial","policy","state","can","be","obtained","through","a","call","to","`","get_initial_state","(",")","`",".","Example","of","simple","use","in","Python",":","py_env","=","PyEnvironment","(",")","policy","=","PyPolicy","(",")","time_step","=","py_env.reset","(",")","policy_state","=","policy.get_initial_state","(",")","acc_reward","=","0","while","not","time_step.is_last","(",")",":","action_step","=","policy.action","(","time_step",",","policy_state",")","policy_state","=","action_step.state","time_step","=","py_env.step","(","action_step.action",")","acc_reward","+=","time_step.reward"]
docstr: Generates next action given the time_step and policy_state.
  
  Args:
    time_step: A `TimeStep` tuple corresponding to `time_step_spec()`.
    policy_state: An optional previous policy_state.
    seed: Seed to use if action uses sampling (optional).
  
  Returns:
    A PolicyStep named tuple containing:
      `action`: A nest of action Arrays matching the `action_spec()`.
      `state`: A nest of policy states to be fed into the next call to action.
      `info`: Optional side information such as action log probabilities.
docstr_tok: ["Generates","next","action","given","the","time_step","and","policy_state",".","Args",":","time_step",":","A","`","TimeStep","`","tuple","corresponding","to","`","time_step_spec","(",")","`",".","policy_state",":","An","optional","previous","policy_state",".","seed",":","Seed","to","use","if","action","uses","sampling","(","optional",")",".","Returns",":","A","PolicyStep","named","tuple","containing",":","`","action","`",":","A","nest","of","action","Arrays","matching","the","`","action_spec","(",")","`",".","`","state","`",":","A","nest","of","policy","states","to","be","fed","into","the","next","call","to","action",".","`","info","`",":","Optional","side","information","such","as","action","log","probabilities","."]
code: def action(
      self,
      time_step: ts.TimeStep,
      policy_state: types.NestedArray = (),
      seed: Optional[types.Seed] = None,
  ) -> policy_step.PolicyStep:
      """Generates next action given the time_step and policy_state.
  
      Args:
        time_step: A `TimeStep` tuple corresponding to `time_step_spec()`.
        policy_state: An optional previous policy_state.
        seed: Seed to use if action uses sampling (optional).
  
      Returns:
        A PolicyStep named tuple containing:
          `action`: A nest of action Arrays matching the `action_spec()`.
          `state`: A nest of policy states to be fed into the next call to action.
          `info`: Optional side information such as action log probabilities.
      """
      if seed is not None:
          return self._action(time_step, policy_state, seed=seed)
      else:
          return self._action(time_step, policy_state)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  from typing import Optional
  import numpy
  import six
  import tensorflow
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.typing import types
  from tf_agents.utils import common
label_desc: Use image node_id 5 for calling the PyPolicy obj's underlying member method code with example usage: obj.action(time_step, policy_state, seed) and returns: self, self