class_docstr: Vectorized environment that serially runs multiple environments.
  
  Example::
  
      >>> import gym
      >>> env = gym.vector.SyncVectorEnv([
      ...     lambda: gym.make("Pendulum-v0", g=9.81),
      ...     lambda: gym.make("Pendulum-v0", g=1.62)
      ... ])
      >>> env.reset()
      array([[-0.8286432 ,  0.5597771 ,  0.90249056],
             [-0.85009176,  0.5266346 ,  0.60007906]], dtype=float32)
class_docstr_tok: ["Vectorized","environment","that","serially","runs","multiple","environments",".","Example",":",":",">",">",">","import","gym",">",">",">","env","=","gym.vector.SyncVectorEnv","(","[","...","lambda",":","gym.make","(","``","Pendulum-v0","''",",","g=9.81",")",",","...","lambda",":","gym.make","(","``","Pendulum-v0","''",",","g=1.62",")","...","]",")",">",">",">","env.reset","(",")","array","(","[","[","-0.8286432",",","0.5597771",",","0.90249056","]",",","[","-0.85009176",",","0.5266346",",","0.60007906","]","]",",","dtype=float32",")"]
docstr: Vectorized environment that serially runs multiple environments.
  
  Args:
      env_fns: iterable of callable functions that create the environments.
      observation_space: Observation space of a single environment. If ``None``,
          then the observation space of the first environment is taken.
      action_space: Action space of a single environment. If ``None``,
          then the action space of the first environment is taken.
      copy: If ``True``, then the :meth:`reset` and :meth:`step` methods return a copy of the observations.
  
  Raises:
      RuntimeError: If the observation space of some sub-environment does not match observation_space
          (or, by default, the observation space of the first sub-environment).
docstr_tok: ["Vectorized","environment","that","serially","runs","multiple","environments",".","Args",":","env_fns",":","iterable","of","callable","functions","that","create","the","environments",".","observation_space",":","Observation","space","of","a","single","environment",".","If","``","None","``",",","then","the","observation","space","of","the","first","environment","is","taken",".","action_space",":","Action","space","of","a","single","environment",".","If","``","None","``",",","then","the","action","space","of","the","first","environment","is","taken",".","copy",":","If","``","True","``",",","then","the",":","meth",":","`","reset","`","and",":","meth",":","`","step","`","methods","return","a","copy","of","the","observations",".","Raises",":","RuntimeError",":","If","the","observation","space","of","some","sub-environment","does","not","match","observation_space","(","or",",","by","default",",","the","observation","space","of","the","first","sub-environment",")","."]
code: def __init__(
      self,
      env_fns: Iterator[Callable[[], Env]],
      observation_space: Space = None,
      action_space: Space = None,
      copy: bool = True,
  ):
      """Vectorized environment that serially runs multiple environments.
  
      Args:
          env_fns: iterable of callable functions that create the environments.
          observation_space: Observation space of a single environment. If ``None``,
              then the observation space of the first environment is taken.
          action_space: Action space of a single environment. If ``None``,
              then the action space of the first environment is taken.
          copy: If ``True``, then the :meth:`reset` and :meth:`step` methods return a copy of the observations.
  
      Raises:
          RuntimeError: If the observation space of some sub-environment does not match observation_space
              (or, by default, the observation space of the first sub-environment).
      """
      self.env_fns = env_fns
      self.envs = [env_fn() for env_fn in env_fns]
      self.copy = copy
      self.metadata = self.envs[0].metadata
  
      if (observation_space is None) or (action_space is None):
          observation_space = (
              observation_space or self.envs[0].observation_space
          )
          action_space = action_space or self.envs[0].action_space
      super().__init__(
          num_envs=len(self.envs),
          observation_space=observation_space,
          action_space=action_space,
      )
  
      self._check_spaces()
      self.observations = create_empty_array(
          self.single_observation_space, n=self.num_envs, fn=np.zeros
      )
      self._rewards = np.zeros((self.num_envs,), dtype=np.float64)
      self._terminateds = np.zeros((self.num_envs,), dtype=np.bool_)
      self._truncateds = np.zeros((self.num_envs,), dtype=np.bool_)
      self._actions = None
  
file_path: gym/gym/vector/sync_vector_env.py
imports: from copy import deepcopy
  from typing import Any, Callable, Iterator, List, Optional, Sequence, Union
  import numpy
  from gym import Env
  from gym.spaces import Space
  from gym.vector.utils import concatenate, create_empty_array, iterate
  from gym.vector.vector_env import VectorEnv
label_desc: Use image node_id 1 to create a new SyncVectorEnv object from inherited base classes: VectorEnv with example: obj = SyncVectorEnv(env_fns, observation_space, action_space, copy)