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","."]
docstr: Initializes a new `TFPyPolicy` instance with an Pyton policy .
  
  Args:
    policy: Python policy implementing `py_policy.PyPolicy`.
    py_policy_is_batched: If False, time_steps will be unbatched before
      passing to py_policy.action(), and a batch dimension will be added to
      the returned action. This will only work with time_steps that have a
      batch dimension of 1. If True, the time_step (input) and action (output)
      are passed exactly as is from/to the py_policy.
    name: The name of this policy. All variables in this module will fall
      under that name. Defaults to the class name.
  
  Raises:
    TypeError: if a non python policy is passed to constructor.
docstr_tok: ["Initializes","a","new","`","TFPyPolicy","`","instance","with","an","Pyton","policy",".","Args",":","policy",":","Python","policy","implementing","`","py_policy.PyPolicy","`",".","py_policy_is_batched",":","If","False",",","time_steps","will","be","unbatched","before","passing","to","py_policy.action","(",")",",","and","a","batch","dimension","will","be","added","to","the","returned","action",".","This","will","only","work","with","time_steps","that","have","a","batch","dimension","of","1",".","If","True",",","the","time_step","(","input",")","and","action","(","output",")","are","passed","exactly","as","is","from\/to","the","py_policy",".","name",":","The","name","of","this","policy",".","All","variables","in","this","module","will","fall","under","that","name",".","Defaults","to","the","class","name",".","Raises",":","TypeError",":","if","a","non","python","policy","is","passed","to","constructor","."]
code: def __init__(
      self,
      policy: py_policy.PyPolicy,
      py_policy_is_batched: bool = False,
      name: Optional[Text] = None,
  ):
      """Initializes a new `TFPyPolicy` instance with an Pyton policy .
  
      Args:
        policy: Python policy implementing `py_policy.PyPolicy`.
        py_policy_is_batched: If False, time_steps will be unbatched before
          passing to py_policy.action(), and a batch dimension will be added to
          the returned action. This will only work with time_steps that have a
          batch dimension of 1. If True, the time_step (input) and action (output)
          are passed exactly as is from/to the py_policy.
        name: The name of this policy. All variables in this module will fall
          under that name. Defaults to the class name.
  
      Raises:
        TypeError: if a non python policy is passed to constructor.
      """
      if not isinstance(policy, py_policy.PyPolicy):
          raise TypeError(
              "Input policy should implement py_policy.PyPolicy, but saw %s."
              % type(policy).__name__
          )
  
      self._py_policy = policy
      self._py_policy_is_batched = py_policy_is_batched
  
      (
          time_step_spec,
          action_spec,
          policy_state_spec,
          info_spec,
      ) = tf.nest.map_structure(
          tensor_spec.from_spec,
          (
              policy.time_step_spec,
              policy.action_spec,
              policy.policy_state_spec,
              policy.info_spec,
          ),
      )
  
      super(TFPyPolicy, self).__init__(
          time_step_spec=time_step_spec,
          action_spec=action_spec,
          policy_state_spec=policy_state_spec,
          info_spec=info_spec,
          clip=False,
          name=name,
          automatic_state_reset=False,
      )
  
      # Output types of py_funcs.
      self._policy_state_dtypes = map_tensor_spec_to_dtypes_list(
          self.policy_state_spec
      )
      self._policy_step_dtypes = map_tensor_spec_to_dtypes_list(
          self.policy_step_spec
      )
  
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 1 to create a new TFPyPolicy object from inherited base classes: tf_policy with example: obj = TFPyPolicy(policy, py_policy_is_batched, name)