class_docstr: Returns actions from the given configuration.
class_docstr_tok: ["Returns","actions","from","the","given","configuration","."]
docstr: Instantiates the scripted policy.
  
  The Action  script can be configured through gin. e.g:
  
  ScriptedPyPolicy.action_script = [
      (1, {  "action1": [[5, 2], [1, 3]],
             "action2": [[4, 6]]},),
      (0, {  "action1": [[8, 1], [9, 2]],
             "action2": [[1, 2]]},),
      (2, {  "action1": [[1, 1], [3, 2]],
             "action2": [[8, 2]]},),
  ]
  
  In this case the first action is executed once, the second scripted action
  is disabled and skipped. Then the third listed action is executed for two
  steps.
  
  Args:
    time_step_spec: A time_step_spec for the policy will interact with.
    action_spec: An action_spec for the environment the policy will interact
      with.
    action_script: A list of 2-tuples of the form (n, nest) where the nest of
      actions follow the action_spec. Each action will be executed for n
      steps.
docstr_tok: ["Instantiates","the","scripted","policy",".","The","Action","script","can","be","configured","through","gin",".","e.g",":","ScriptedPyPolicy.action_script","=","[","(","1",",","{","``","action1","''",":","[","[","5",",","2","]",",","[","1",",","3","]","]",",","``","action2","''",":","[","[","4",",","6","]","]","}",",",")",",","(","0",",","{","``","action1","''",":","[","[","8",",","1","]",",","[","9",",","2","]","]",",","``","action2","''",":","[","[","1",",","2","]","]","}",",",")",",","(","2",",","{","``","action1","''",":","[","[","1",",","1","]",",","[","3",",","2","]","]",",","``","action2","''",":","[","[","8",",","2","]","]","}",",",")",",","]","In","this","case","the","first","action","is","executed","once",",","the","second","scripted","action","is","disabled","and","skipped",".","Then","the","third","listed","action","is","executed","for","two","steps",".","Args",":","time_step_spec",":","A","time_step_spec","for","the","policy","will","interact","with",".","action_spec",":","An","action_spec","for","the","environment","the","policy","will","interact","with",".","action_script",":","A","list","of","2-tuples","of","the","form","(","n",",","nest",")","where","the","nest","of","actions","follow","the","action_spec",".","Each","action","will","be","executed","for","n","steps","."]
code: def __init__(
      self,
      time_step_spec: ts.TimeStep,
      action_spec: types.NestedArraySpec,
      action_script: Sequence[Tuple[int, types.NestedArray]],
  ):
      """Instantiates the scripted policy.
  
      The Action  script can be configured through gin. e.g:
  
      ScriptedPyPolicy.action_script = [
          (1, {  "action1": [[5, 2], [1, 3]],
                 "action2": [[4, 6]]},),
          (0, {  "action1": [[8, 1], [9, 2]],
                 "action2": [[1, 2]]},),
          (2, {  "action1": [[1, 1], [3, 2]],
                 "action2": [[8, 2]]},),
      ]
  
      In this case the first action is executed once, the second scripted action
      is disabled and skipped. Then the third listed action is executed for two
      steps.
  
      Args:
        time_step_spec: A time_step_spec for the policy will interact with.
        action_spec: An action_spec for the environment the policy will interact
          with.
        action_script: A list of 2-tuples of the form (n, nest) where the nest of
          actions follow the action_spec. Each action will be executed for n
          steps.
      """
      if time_step_spec is None:
          time_step_spec = ts.time_step_spec()
      super(ScriptedPyPolicy, self).__init__(
          time_step_spec=time_step_spec, action_spec=action_spec
      )
  
      self._action_script = action_script
  
file_path: agents/tf_agents/policies/scripted_py_policy.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Sequence, Tuple
  from absl import logging
  import numpy
  from tf_agents.policies import py_policy
  from tf_agents.specs import array_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 to create a new ScriptedPyPolicy object from inherited base classes: py_policy with example: obj = ScriptedPyPolicy(time_step_spec, action_spec, action_script)