class_docstr: Batch together multiple py policies and act as a single batch.
  
  The policies should only access shared python variables using
  shared mutex locks (from the threading module).
class_docstr_tok: ["Batch","together","multiple","py","policies","and","act","as","a","single","batch",".","The","policies","should","only","access","shared","python","variables","using","shared","mutex","locks","(","from","the","threading","module",")","."]
docstr: Batch together multiple (non-batched) py policies.
  
  The policies can be different but must use the same action and
  observation specs.
  
  Args:
    policies: List python policies (must be non-batched).
    multithreading: Python bool describing whether interactions with the given
      policies should happen in their own threadpool.  If `False`, then all
      interaction is performed serially in the current thread.  This may be
      combined with `TFPyPolicy(..., py_policy_is_batched=True)` to ensure
      that multiple policies are all run in the same thread.
  
  Raises:
    ValueError: If policies is not a list or tuple, or is zero length, or if
      one of the policies is already batched.
    ValueError: If the action or observation specs don't match.
docstr_tok: ["Batch","together","multiple","(","non-batched",")","py","policies",".","The","policies","can","be","different","but","must","use","the","same","action","and","observation","specs",".","Args",":","policies",":","List","python","policies","(","must","be","non-batched",")",".","multithreading",":","Python","bool","describing","whether","interactions","with","the","given","policies","should","happen","in","their","own","threadpool",".","If","`","False","`",",","then","all","interaction","is","performed","serially","in","the","current","thread",".","This","may","be","combined","with","`","TFPyPolicy","(","...",",","py_policy_is_batched=True",")","`","to","ensure","that","multiple","policies","are","all","run","in","the","same","thread",".","Raises",":","ValueError",":","If","policies","is","not","a","list","or","tuple",",","or","is","zero","length",",","or","if","one","of","the","policies","is","already","batched",".","ValueError",":","If","the","action","or","observation","specs","do","n't","match","."]
code: def __init__(
      self,
      policies: Sequence[py_policy.PyPolicy],
      multithreading: bool = True,
  ):
      """Batch together multiple (non-batched) py policies.
  
      The policies can be different but must use the same action and
      observation specs.
  
      Args:
        policies: List python policies (must be non-batched).
        multithreading: Python bool describing whether interactions with the given
          policies should happen in their own threadpool.  If `False`, then all
          interaction is performed serially in the current thread.  This may be
          combined with `TFPyPolicy(..., py_policy_is_batched=True)` to ensure
          that multiple policies are all run in the same thread.
  
      Raises:
        ValueError: If policies is not a list or tuple, or is zero length, or if
          one of the policies is already batched.
        ValueError: If the action or observation specs don't match.
      """
      if not isinstance(policies, (list, tuple)):
          raise ValueError(
              "policies must be a list or tuple.  Got: %s" % policies
          )
  
      self._parallel_execution = multithreading
      self._policies = policies
      self._num_policies = len(policies)
      self._time_step_spec = self._policies[0].time_step_spec
      self._action_spec = self._policies[0].action_spec
      self._policy_state_spec = self._policies[0].policy_state_spec
      self._info_spec = self._policies[0].info_spec
      self._policy_step_spec = self._policies[0].policy_step_spec
      self._trajectory_spec = self._policies[0].trajectory_spec
      self._collect_data_spec = self._policies[0].collect_data_spec
      self._observation_and_action_constraint_splitter = self._policies[
          0
      ].observation_and_action_constraint_splitter
  
      self._validate_spec(
          py_policy.PyPolicy.time_step_spec, self._time_step_spec
      )
      self._validate_spec(
          py_policy.PyPolicy.action_spec, self._action_spec
      )
      self._validate_spec(
          py_policy.PyPolicy.policy_state_spec, self._policy_state_spec
      )
      self._validate_spec(py_policy.PyPolicy.info_spec, self._info_spec)
      self._validate_spec(
          py_policy.PyPolicy.policy_step_spec, self._policy_step_spec
      )
      self._validate_spec(
          py_policy.PyPolicy.trajectory_spec, self._trajectory_spec
      )
      self._validate_spec(
          py_policy.PyPolicy.collect_data_spec, self._collect_data_spec
      )
      self._validate_spec(
          py_policy.PyPolicy.observation_and_action_constraint_splitter,
          self._observation_and_action_constraint_splitter,
      )
  
      # Create a multiprocessing threadpool for execution.
      if multithreading:
          self._pool = mp_threads.Pool(self._num_policies)
  
      super(BatchedPyPolicy, self).__init__(
          self._time_step_spec,
          self._action_spec,
          self._policy_state_spec,
          self._info_spec,
          self._observation_and_action_constraint_splitter,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from multiprocessing import dummy
  from typing import Sequence, Optional
  import gin
  from tf_agents.policies import py_policy
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 1 to create a new BatchedPyPolicy object from inherited base classes: py_policy with example: obj = BatchedPyPolicy(policies, multithreading)