class_docstr: Vectorized environment that runs multiple environments in parallel.
  
  It uses ``multiprocessing`` processes, and pipes for communication.
  
  Example::
  
      >>> import gym
      >>> env = gym.vector.AsyncVectorEnv([
      ...     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","runs","multiple","environments","in","parallel",".","It","uses","``","multiprocessing","``","processes",",","and","pipes","for","communication",".","Example",":",":",">",">",">","import","gym",">",">",">","env","=","gym.vector.AsyncVectorEnv","(","[","...","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: Close the environments & clean up the extra resources (processes and pipes).
  
  Args:
      timeout: Number of seconds before the call to :meth:`close` times out. If ``None``,
          the call to :meth:`close` never times out. If the call to :meth:`close`
          times out, then all processes are terminated.
      terminate: If ``True``, then the :meth:`close` operation is forced and all processes are terminated.
  
  Raises:
      TimeoutError: If :meth:`close` timed out.
docstr_tok: ["Close","the","environments","&","clean","up","the","extra","resources","(","processes","and","pipes",")",".","Args",":","timeout",":","Number","of","seconds","before","the","call","to",":","meth",":","`","close","`","times","out",".","If","``","None","``",",","the","call","to",":","meth",":","`","close","`","never","times","out",".","If","the","call","to",":","meth",":","`","close","`","times","out",",","then","all","processes","are","terminated",".","terminate",":","If","``","True","``",",","then","the",":","meth",":","`","close","`","operation","is","forced","and","all","processes","are","terminated",".","Raises",":","TimeoutError",":","If",":","meth",":","`","close","`","timed","out","."]
code: def close_extras(
      self,
      timeout: Optional[Union[int, float]] = None,
      terminate: bool = False,
  ):
      """Close the environments & clean up the extra resources (processes and pipes).
  
      Args:
          timeout: Number of seconds before the call to :meth:`close` times out. If ``None``,
              the call to :meth:`close` never times out. If the call to :meth:`close`
              times out, then all processes are terminated.
          terminate: If ``True``, then the :meth:`close` operation is forced and all processes are terminated.
  
      Raises:
          TimeoutError: If :meth:`close` timed out.
      """
      timeout = 0 if terminate else timeout
      try:
          if self._state != AsyncState.DEFAULT:
              logger.warn(
                  f"Calling `close` while waiting for a pending call to `{self._state.value}` to complete."
              )
              function = getattr(self, f"{self._state.value}_wait")
              function(timeout)
      except mp.TimeoutError:
          terminate = True
  
      if terminate:
          for process in self.processes:
              if process.is_alive():
                  process.terminate()
      else:
          for pipe in self.parent_pipes:
              if (pipe is not None) and (not pipe.closed):
                  pipe.send(("close", None))
          for pipe in self.parent_pipes:
              if (pipe is not None) and (not pipe.closed):
                  pipe.recv()
  
      for pipe in self.parent_pipes:
          if pipe is not None:
              pipe.close()
      for process in self.processes:
          process.join()
  
imports: import multiprocessing
  import sys
  import time
  from copy import deepcopy
  from enum import Enum
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import gym
  from gym import logger
  from gym.core import ObsType
  from gym.error import AlreadyPendingCallError, ClosedEnvironmentError, CustomSpaceError, NoAsyncCallError
  from gym.vector.utils import CloudpickleWrapper, clear_mpi_env_vars, concatenate, create_empty_array, create_shared_memory, iterate, read_from_shared_memory, write_to_shared_memory
  from gym.vector.vector_env import VectorEnv
label_desc: Use image node_id 9 for calling the AsyncVectorEnv obj's underlying member method code with example usage: obj.close_extras(timeout, terminate) without return types