class_docstr: Batch together environments and simulate them in external processes.
  
  The environments are created in external processes by calling the provided
  callables. This can be an environment class, or a function creating the
  environment and potentially wrapping it. The returned environment should not
  access global variables.
class_docstr_tok: ["Batch","together","environments","and","simulate","them","in","external","processes",".","The","environments","are","created","in","external","processes","by","calling","the","provided","callables",".","This","can","be","an","environment","class",",","or","a","function","creating","the","environment","and","potentially","wrapping","it",".","The","returned","environment","should","not","access","global","variables","."]
docstr: Batch together environments and simulate them in external processes.
  
  The environments can be different but must use the same action and
  observation specs.
  
  Args:
    env_constructors: List of callables that create environments.
    start_serially: Whether to start environments serially or in parallel.
    blocking: Whether to step environments one after another.
    flatten: Boolean, whether to use flatten action and time_steps during
      communication to reduce overhead.
  
  Raises:
    ValueError: If the action or observation specs don't match.
docstr_tok: ["Batch","together","environments","and","simulate","them","in","external","processes",".","The","environments","can","be","different","but","must","use","the","same","action","and","observation","specs",".","Args",":","env_constructors",":","List","of","callables","that","create","environments",".","start_serially",":","Whether","to","start","environments","serially","or","in","parallel",".","blocking",":","Whether","to","step","environments","one","after","another",".","flatten",":","Boolean",",","whether","to","use","flatten","action","and","time_steps","during","communication","to","reduce","overhead",".","Raises",":","ValueError",":","If","the","action","or","observation","specs","do","n't","match","."]
code: def __init__(
      self,
      env_constructors: Sequence[EnvConstructor],
      start_serially: bool = True,
      blocking: bool = False,
      flatten: bool = False,
  ):
      """Batch together environments and simulate them in external processes.
  
      The environments can be different but must use the same action and
      observation specs.
  
      Args:
        env_constructors: List of callables that create environments.
        start_serially: Whether to start environments serially or in parallel.
        blocking: Whether to step environments one after another.
        flatten: Boolean, whether to use flatten action and time_steps during
          communication to reduce overhead.
  
      Raises:
        ValueError: If the action or observation specs don't match.
      """
      super(ParallelPyEnvironment, self).__init__()
      if any([not callable(ctor) for ctor in env_constructors]):
          raise TypeError(
              "Found non-callable `env_constructors` in `ParallelPyEnvironment` "
              "__init__ call. Did you accidentally pass in environment instances "
              "instead of constructors? Got: {}".format(
                  env_constructors
              )
          )
      self._envs = [
          ProcessPyEnvironment(ctor, flatten=flatten)
          for ctor in env_constructors
      ]
      self._num_envs = len(env_constructors)
      self._blocking = blocking
      self._start_serially = start_serially
      self.start()
      self._action_spec = self._envs[0].action_spec()
      self._observation_spec = self._envs[0].observation_spec()
      self._time_step_spec = self._envs[0].time_step_spec()
      self._parallel_execution = True
      if any(
          env.action_spec() != self._action_spec for env in self._envs
      ):
          raise ValueError(
              "All environments must have the same action spec."
          )
      if any(
          env.time_step_spec() != self._time_step_spec
          for env in self._envs
      ):
          raise ValueError(
              "All environments must have the same time_step_spec."
          )
      self._flatten = flatten
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import atexit
  import sys
  import traceback
  from typing import Any, Callable, Sequence, Text, Union
  from absl import logging
  import cloudpickle
  import gin
  import numpy
  import tensorflow
  from tf_agents.environments import py_environment
  from tf_agents.system import system_multiprocessing
  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 ParallelPyEnvironment object from inherited base classes: py_environment with example: obj = ParallelPyEnvironment(env_constructors, start_serially, blocking, flatten)