### Install Stoa with All Adapters Source: https://github.com/edantoledo/stoa/blob/main/README.md Installs the 'stoa-env' library with all available environment adapters, providing support for all integrated RL libraries. ```Bash pip install "stoa-env[all]" ``` -------------------------------- ### Install Stoa Core Library Source: https://github.com/edantoledo/stoa/blob/main/README.md Installs the core 'stoa-env' library, which includes the main API and wrappers but excludes specific environment adapters. ```Bash pip install stoa-env ``` -------------------------------- ### Install Stoa with Brax Adapter Source: https://github.com/edantoledo/stoa/blob/main/README.md Installs the 'stoa-env' library along with the Brax environment adapter, allowing integration with Brax environments. ```Bash pip install "stoa-env[brax]" ``` -------------------------------- ### Install Stoa with Gymnax Adapter Source: https://github.com/edantoledo/stoa/blob/main/README.md Installs the 'stoa-env' library along with the Gymnax environment adapter, enabling the use of Gymnax environments within Stoa. ```Bash pip install "stoa-env[gymnax]" ``` -------------------------------- ### Adapt Gymnax Environment and Apply Wrappers in JAX Source: https://github.com/edantoledo/stoa/blob/main/README.md Demonstrates adapting a Gymnax environment to the Stoa interface, applying wrappers like AutoResetWrapper and RecordEpisodeMetrics, and JIT compiling reset and step functions for performance. It also shows basic interaction with the environment, including sampling actions and accessing episode metrics. ```Python import jax import gymnax from stoa import GymnaxToStoa, FlattenObservationWrapper, AutoResetWrapper, RecordEpisodeMetrics # 1. Instantiate a base environment from a supported library gymnax_env, env_params = gymnax.make("CartPole-v1") # 2. Adapt the environment to the Stoa interface env = GymnaxToStoa(gymnax_env, env_params) # 3. Apply standard wrappers # Note: The order of wrappers matters. env = AutoResetWrapper(env, next_obs_in_extras=True) env = RecordEpisodeMetrics(env) # JIT compile the reset and step functions for performance env.reset = jax.jit(env.reset) env.step = jax.jit(env.step) # 4. Interact with the environment rng_key = jax.random.PRNGKey(0) state, timestep = env.reset(rng_key) total_reward = 0 for _ in range(100): action = env.action_space().sample(rng_key) state, timestep = env.step(state, action) total_reward += timestep.reward if timestep.last(): # Access metrics recorded by the RecordEpisodeMetrics wrapper episode_return = timestep.extras['episode_metrics']['episode_return'] print(f"Episode finished. Return: {episode_return}") # The state has been auto-reset, so we can continue the loop total_reward = 0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.