class_docstr: The lowest-level env interface used by RLlib for sampling.
  
  BaseEnv models multiple agents executing asynchronously in multiple
  vectorized sub-environments. A call to `poll()` returns observations from
  ready agents keyed by their sub-environment ID and agent IDs, and
  actions for those agents can be sent back via `send_actions()`.
  
  All other RLlib supported env types can be converted to BaseEnv.
  RLlib handles these conversions internally in RolloutWorker, for example:
  
  gym.Env => rllib.VectorEnv => rllib.BaseEnv
  rllib.MultiAgentEnv (is-a gym.Env) => rllib.VectorEnv => rllib.BaseEnv
  rllib.ExternalEnv => rllib.BaseEnv
  
  .. testcode::
      :skipif: True
  
      MyBaseEnv = ...
      env = MyBaseEnv()
      obs, rewards, terminateds, truncateds, infos, off_policy_actions = (
          env.poll()
      )
      print(obs)
  
      env.send_actions({
        "env_0": {
          "car_0": 0,
          "car_1": 1,
        }, ...
      })
      obs, rewards, terminateds, truncateds, infos, off_policy_actions = (
          env.poll()
      )
      print(obs)
  
      print(terminateds)
  
  .. testoutput::
  
      {
          "env_0": {
              "car_0": [2.4, 1.6],
              "car_1": [3.4, -3.2],
          },
          "env_1": {
              "car_0": [8.0, 4.1],
          },
          "env_2": {
              "car_0": [2.3, 3.3],
              "car_1": [1.4, -0.2],
              "car_3": [1.2, 0.1],
          },
      }
      {
          "env_0": {
              "car_0": [4.1, 1.7],
              "car_1": [3.2, -4.2],
          }, ...
      }
      {
          "env_0": {
              "__all__": False,
              "car_0": False,
              "car_1": True,
          }, ...
      }
class_docstr_tok: ["The","lowest-level","env","interface","used","by","RLlib","for","sampling",".","BaseEnv","models","multiple","agents","executing","asynchronously","in","multiple","vectorized","sub-environments",".","A","call","to","`","poll","(",")","`","returns","observations","from","ready","agents","keyed","by","their","sub-environment","ID","and","agent","IDs",",","and","actions","for","those","agents","can","be","sent","back","via","`","send_actions","(",")","`",".","All","other","RLlib","supported","env","types","can","be","converted","to","BaseEnv",".","RLlib","handles","these","conversions","internally","in","RolloutWorker",",","for","example",":","gym.Env","=",">","rllib.VectorEnv","=",">","rllib.BaseEnv","rllib.MultiAgentEnv","(","is-a","gym.Env",")","=",">","rllib.VectorEnv","=",">","rllib.BaseEnv","rllib.ExternalEnv","=",">","rllib.BaseEnv","..","testcode",":",":",":","skipif",":","True","MyBaseEnv","=","...","env","=","MyBaseEnv","(",")","obs",",","rewards",",","terminateds",",","truncateds",",","infos",",","off_policy_actions","=","(","env.poll","(",")",")","print","(","obs",")","env.send_actions","(","{","``","env_0","''",":","{","``","car_0","''",":","0",",","``","car_1","''",":","1",",","}",",","...","}",")","obs",",","rewards",",","terminateds",",","truncateds",",","infos",",","off_policy_actions","=","(","env.poll","(",")",")","print","(","obs",")","print","(","terminateds",")","..","testoutput",":",":","{","``","env_0","''",":","{","``","car_0","''",":","[","2.4",",","1.6","]",",","``","car_1","''",":","[","3.4",",","-3.2","]",",","}",",","``","env_1","''",":","{","``","car_0","''",":","[","8.0",",","4.1","]",",","}",",","``","env_2","''",":","{","``","car_0","''",":","[","2.3",",","3.3","]",",","``","car_1","''",":","[","1.4",",","-0.2","]",",","``","car_3","''",":","[","1.2",",","0.1","]",",","}",",","}","{","``","env_0","''",":","{","``","car_0","''",":","[","4.1",",","1.7","]",",","``","car_1","''",":","[","3.2",",","-4.2","]",",","}",",","...","}","{","``","env_0","''",":","{","``","__all__","''",":","False",",","``","car_0","''",":","False",",","``","car_1","''",":","True",",","}",",","...","}"]
docstr: Converts an RLlib-supported env into a BaseEnv object.
  
  Supported types for the `env` arg are gym.Env, BaseEnv,
  VectorEnv, MultiAgentEnv, ExternalEnv, or ExternalMultiAgentEnv.
  
  The resulting BaseEnv is always vectorized (contains n
  sub-environments) to support batched forward passes, where n may also
  be 1. BaseEnv also supports async execution via the `poll` and
  `send_actions` methods and thus supports external simulators.
  
  TODO: Support gym3 environments, which are already vectorized.
  
  Args:
      env: An already existing environment of any supported env type
          to convert/wrap into a BaseEnv. Supported types are gym.Env,
          BaseEnv, VectorEnv, MultiAgentEnv, ExternalEnv, and
          ExternalMultiAgentEnv.
      make_env: A callable taking an int as input (which indicates the
          number of individual sub-environments within the final
          vectorized BaseEnv) and returning one individual
          sub-environment.
      num_envs: The number of sub-environments to create in the
          resulting (vectorized) BaseEnv. The already existing `env`
          will be one of the `num_envs`.
      remote_envs: Whether each sub-env should be a @ray.remote actor.
          You can set this behavior in your config via the
          `remote_worker_envs=True` option.
      remote_env_batch_wait_ms: The wait time (in ms) to poll remote
          sub-environments for, if applicable. Only used if
          `remote_envs` is True.
      policy_config: Optional policy config dict.
  
  Returns:
      The resulting BaseEnv object.
docstr_tok: ["Converts","an","RLlib-supported","env","into","a","BaseEnv","object",".","Supported","types","for","the","`","env","`","arg","are","gym.Env",",","BaseEnv",",","VectorEnv",",","MultiAgentEnv",",","ExternalEnv",",","or","ExternalMultiAgentEnv",".","The","resulting","BaseEnv","is","always","vectorized","(","contains","n","sub-environments",")","to","support","batched","forward","passes",",","where","n","may","also","be","1",".","BaseEnv","also","supports","async","execution","via","the","`","poll","`","and","`","send_actions","`","methods","and","thus","supports","external","simulators",".","TODO",":","Support","gym3","environments",",","which","are","already","vectorized",".","Args",":","env",":","An","already","existing","environment","of","any","supported","env","type","to","convert\/wrap","into","a","BaseEnv",".","Supported","types","are","gym.Env",",","BaseEnv",",","VectorEnv",",","MultiAgentEnv",",","ExternalEnv",",","and","ExternalMultiAgentEnv",".","make_env",":","A","callable","taking","an","int","as","input","(","which","indicates","the","number","of","individual","sub-environments","within","the","final","vectorized","BaseEnv",")","and","returning","one","individual","sub-environment",".","num_envs",":","The","number","of","sub-environments","to","create","in","the","resulting","(","vectorized",")","BaseEnv",".","The","already","existing","`","env","`","will","be","one","of","the","`","num_envs","`",".","remote_envs",":","Whether","each","sub-env","should","be","a","@","ray.remote","actor",".","You","can","set","this","behavior","in","your","config","via","the","`","remote_worker_envs=True","`","option",".","remote_env_batch_wait_ms",":","The","wait","time","(","in","ms",")","to","poll","remote","sub-environments","for",",","if","applicable",".","Only","used","if","`","remote_envs","`","is","True",".","policy_config",":","Optional","policy","config","dict",".","Returns",":","The","resulting","BaseEnv","object","."]
code: def to_base_env(
      self,
      make_env: Optional[Callable[[int], EnvType]] = None,
      num_envs: int = 1,
      remote_envs: bool = False,
      remote_env_batch_wait_ms: int = 0,
      restart_failed_sub_environments: bool = False,
  ) -> "BaseEnv":
      """Converts an RLlib-supported env into a BaseEnv object.
  
      Supported types for the `env` arg are gym.Env, BaseEnv,
      VectorEnv, MultiAgentEnv, ExternalEnv, or ExternalMultiAgentEnv.
  
      The resulting BaseEnv is always vectorized (contains n
      sub-environments) to support batched forward passes, where n may also
      be 1. BaseEnv also supports async execution via the `poll` and
      `send_actions` methods and thus supports external simulators.
  
      TODO: Support gym3 environments, which are already vectorized.
  
      Args:
          env: An already existing environment of any supported env type
              to convert/wrap into a BaseEnv. Supported types are gym.Env,
              BaseEnv, VectorEnv, MultiAgentEnv, ExternalEnv, and
              ExternalMultiAgentEnv.
          make_env: A callable taking an int as input (which indicates the
              number of individual sub-environments within the final
              vectorized BaseEnv) and returning one individual
              sub-environment.
          num_envs: The number of sub-environments to create in the
              resulting (vectorized) BaseEnv. The already existing `env`
              will be one of the `num_envs`.
          remote_envs: Whether each sub-env should be a @ray.remote actor.
              You can set this behavior in your config via the
              `remote_worker_envs=True` option.
          remote_env_batch_wait_ms: The wait time (in ms) to poll remote
              sub-environments for, if applicable. Only used if
              `remote_envs` is True.
          policy_config: Optional policy config dict.
  
      Returns:
          The resulting BaseEnv object.
      """
      return self
  
imports: import logging
  from typing import Callable, Tuple, Optional, List, Dict, Any, TYPE_CHECKING, Union, Set
  import gymnasium
  import ray
  from ray.rllib.utils.annotations import Deprecated, DeveloperAPI, PublicAPI
  from ray.rllib.utils.typing import AgentID, EnvID, EnvType, MultiEnvDict
label_desc: Use image node_id 1 for calling the BaseEnv obj's underlying member method code with example usage: obj.to_base_env(make_env, num_envs, remote_envs, remote_env_batch_wait_ms, restart_failed_sub_environments) and returns: self