class_docstr: Internal wrapper to translate any gym.Envs into a VectorEnv object.
class_docstr_tok: ["Internal","wrapper","to","translate","any","gym.Envs","into","a","VectorEnv","object","."]
docstr: Initializes a _VectorizedGymEnv object.
  
  Args:
      make_env: Factory that produces a new gym.Env taking the sub-env's
          vector index as only arg. Must be defined if the
          number of `existing_envs` is less than `num_envs`.
      existing_envs: Optional list of already instantiated sub
          environments.
      num_envs: Total number of sub environments in this VectorEnv.
      action_space: The action space. If None, use existing_envs[0]'s
          action space.
      observation_space: The observation space. If None, use
          existing_envs[0]'s observation space.
      restart_failed_sub_environments: If True and any sub-environment (within
          a vectorized env) throws any error during env stepping, we will try to
          restart the faulty sub-environment. This is done
          without disturbing the other (still intact) sub-environments.
code: def __init__(
      self,
      make_env: Optional[Callable[[int], EnvType]] = None,
      existing_envs: Optional[List[gym.Env]] = None,
      num_envs: int = 1,
      *,
      observation_space: Optional[gym.Space] = None,
      action_space: Optional[gym.Space] = None,
      restart_failed_sub_environments: bool = False,
      # Deprecated. These seem to have never been used.
      env_config=None,
      policy_config=None,
  ):
      """Initializes a _VectorizedGymEnv object.
  
      Args:
          make_env: Factory that produces a new gym.Env taking the sub-env's
              vector index as only arg. Must be defined if the
              number of `existing_envs` is less than `num_envs`.
          existing_envs: Optional list of already instantiated sub
              environments.
          num_envs: Total number of sub environments in this VectorEnv.
          action_space: The action space. If None, use existing_envs[0]'s
              action space.
          observation_space: The observation space. If None, use
              existing_envs[0]'s observation space.
          restart_failed_sub_environments: If True and any sub-environment (within
              a vectorized env) throws any error during env stepping, we will try to
              restart the faulty sub-environment. This is done
              without disturbing the other (still intact) sub-environments.
      """
      self.envs = existing_envs
      self.make_env = make_env
      self.restart_failed_sub_environments = (
          restart_failed_sub_environments
      )
  
      # Fill up missing envs (so we have exactly num_envs sub-envs in this
      # VectorEnv.
      while len(self.envs) < num_envs:
          self.envs.append(make_env(len(self.envs)))
  
      super().__init__(
          observation_space=observation_space
          or self.envs[0].observation_space,
          action_space=action_space or self.envs[0].action_space,
          num_envs=num_envs,
      )
  
imports: import logging
  import gymnasium
  import numpy
  from typing import Callable, List, Optional, Tuple, Union, Set
  from ray.rllib.env.base_env import BaseEnv, _DUMMY_AGENT_ID
  from ray.rllib.utils.annotations import Deprecated, override, PublicAPI
  from ray.rllib.utils.typing import EnvActionType, EnvID, EnvInfoDict, EnvObsType, EnvType, MultiEnvDict, AgentID
  from ray.util import log_once
label_desc: Use image node_id 1 to create a new _VectorizedGymEnv object from inherited base classes: VectorEnv with example: obj = _VectorizedGymEnv(make_env, existing_envs, num_envs)