class_docstr: Returns actions from the given configuration.
class_docstr_tok: ["Returns","actions","from","the","given","configuration","."]
code: def _action(
      self, time_step, policy_state, seed: Optional[types.Seed] = None
  ):
      del time_step  # Unused.
      del seed  # Unused.
      if policy_state is None:
          policy_state = [0, 0]
  
      (
          action_index,
          num_repeats,
      ) = policy_state  #  pylint: disable=unpacking-non-sequence
  
      def _check_episode_length():
          if action_index >= len(self._action_script):
              raise ValueError(
                  "Episode is longer than the provided scripted policy. Consider "
                  "setting a TimeLimit wrapper that stops episodes within the length"
                  " of your scripted policy."
              )
  
      _check_episode_length()
      n, current_action = self._action_script[action_index]
  
      # If the policy has been executed n times get the next scripted action.
      # Allow users to disable entries in the scripted policy by setting n <= 0.
      while num_repeats >= n:
          action_index += 1
          num_repeats = 0
          _check_episode_length()
          n, current_action = self._action_script[action_index]
  
      num_repeats += 1
  
      # To make it easier for the user we allow the actions in the script to be
      # lists instead of numpy arrays. Checking the arrays_nest requires us to
      # have the leaves be objects and not lists so we lift them into numpy
      # arrays.
      def actions_as_array(action_spec, action):
          return np.asarray(action, dtype=action_spec.dtype)
  
      current_action = nest.map_structure_up_to(
          self._action_spec,
          actions_as_array,
          self._action_spec,
          current_action,
      )
  
      if not array_spec.check_arrays_nest(
          current_action, self._action_spec
      ):
          raise ValueError(
              "Action at index {} does not match the environment's action_spec. "
              "Got: {}. Expected {}.".format(
                  action_index, current_action, self._action_spec
              )
          )
  
      logging.info("Policy_state: %r", policy_state)
      return policy_step.PolicyStep(
          current_action, [action_index, num_repeats]
      )
  
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 3 for calling the ScriptedPyPolicy obj's underlying member method code with example usage: obj._action(time_step, policy_state, seed) and returns: policy_step, np