class_docstr: Base class for py_policy instances of TF policies in Eager mode.
  
  Handles adding and removing batch dimensions from the actions and time_steps.
  Note if you have a tf_policy you should directly use the PyTFEagerPolicy class
  instead of this Base.
class_docstr_tok: ["Base","class","for","py_policy","instances","of","TF","policies","in","Eager","mode",".","Handles","adding","and","removing","batch","dimensions","from","the","actions","and","time_steps",".","Note","if","you","have","a","tf_policy","you","should","directly","use","the","PyTFEagerPolicy","class","instead","of","this","Base","."]
docstr: Creates a new instance of the policy.
  
  Args:
    policy: `tf_policy.TFPolicy` instance to wrap and expose as a py_policy.
    time_step_spec: A `TimeStep` ArraySpec of the expected time_steps. Usually
      provided by the user to the subclass.
    action_spec: A nest of BoundedArraySpec representing the actions. Usually
      provided by the user to the subclass.
    policy_state_spec: A nest of ArraySpec representing the policy state.
      Provided by the subclass, not directly by the user.
    info_spec: A nest of ArraySpec representing the policy info. Provided by
      the subclass, not directly by the user.
    use_tf_function: Wraps the use of `policy.action` in a tf.function call
      which can help speed up execution.
    batch_time_steps:  Wether time_steps should be batched before being passed
      to the wrapped policy. Leave as True unless you are dealing with a
      batched environment, in which case you want to skip the batching as that
      dim will already be present.
docstr_tok: ["Creates","a","new","instance","of","the","policy",".","Args",":","policy",":","`","tf_policy.TFPolicy","`","instance","to","wrap","and","expose","as","a","py_policy",".","time_step_spec",":","A","`","TimeStep","`","ArraySpec","of","the","expected","time_steps",".","Usually","provided","by","the","user","to","the","subclass",".","action_spec",":","A","nest","of","BoundedArraySpec","representing","the","actions",".","Usually","provided","by","the","user","to","the","subclass",".","policy_state_spec",":","A","nest","of","ArraySpec","representing","the","policy","state",".","Provided","by","the","subclass",",","not","directly","by","the","user",".","info_spec",":","A","nest","of","ArraySpec","representing","the","policy","info",".","Provided","by","the","subclass",",","not","directly","by","the","user",".","use_tf_function",":","Wraps","the","use","of","`","policy.action","`","in","a","tf.function","call","which","can","help","speed","up","execution",".","batch_time_steps",":","Wether","time_steps","should","be","batched","before","being","passed","to","the","wrapped","policy",".","Leave","as","True","unless","you","are","dealing","with","a","batched","environment",",","in","which","case","you","want","to","skip","the","batching","as","that","dim","will","already","be","present","."]
code: def __init__(
      self,
      policy: tf_policy.TFPolicy,
      time_step_spec: ts.TimeStep,
      action_spec: types.NestedArraySpec,
      policy_state_spec: types.NestedArraySpec,
      info_spec: types.NestedArraySpec,
      use_tf_function: bool = False,
      batch_time_steps=True,
  ):
      """Creates a new instance of the policy.
  
      Args:
        policy: `tf_policy.TFPolicy` instance to wrap and expose as a py_policy.
        time_step_spec: A `TimeStep` ArraySpec of the expected time_steps. Usually
          provided by the user to the subclass.
        action_spec: A nest of BoundedArraySpec representing the actions. Usually
          provided by the user to the subclass.
        policy_state_spec: A nest of ArraySpec representing the policy state.
          Provided by the subclass, not directly by the user.
        info_spec: A nest of ArraySpec representing the policy info. Provided by
          the subclass, not directly by the user.
        use_tf_function: Wraps the use of `policy.action` in a tf.function call
          which can help speed up execution.
        batch_time_steps:  Wether time_steps should be batched before being passed
          to the wrapped policy. Leave as True unless you are dealing with a
          batched environment, in which case you want to skip the batching as that
          dim will already be present.
      """
      self._policy = policy
      self._use_tf_function = use_tf_function
      if self._use_tf_function:
          self._policy_action_fn = common.function(policy.action)
      else:
          self._policy_action_fn = policy.action
      self._batch_time_steps = batch_time_steps
      super(PyTFEagerPolicyBase, self).__init__(
          time_step_spec, action_spec, policy_state_spec, info_spec
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from typing import Optional, Text
  from absl import logging
  import gin
  import tensorflow
  from tf_agents.policies import policy_saver
  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 time_step
  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 1 to create a new PyTFEagerPolicyBase object from inherited base classes: py_policy with example: obj = PyTFEagerPolicyBase(policy, time_step_spec, action_spec, policy_state_spec, info_spec, use_tf_function, batch_time_steps)