# tf_agents.environments.suite_gym.wrap_env

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/suite_gym.py#L100-L158) |

Wraps given gym environment with TF Agent's GymWrapper.

    tf_agents.environments.suite_gym.wrap_env(
        gym_env: gym.Env,
        discount: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Float = 1.0,
        max_episode_steps: Optional[types.Int] = None,
        gym_env_wrappers: Sequence[https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/GymEnvWrapper] = (),
        time_limit_wrapper: https://www.tensorflow.org/agents/api_docs/python/tf_agents/environments/suite_gym/TimeLimitWrapperType = https://www.tensorflow.org/agents/api_docs/python/tf_agents/environments/TimeLimit,
        env_wrappers: Sequence[https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/PyEnvWrapper] = (),
        spec_dtype_map: Optional[Dict[gym.Space, np.dtype]] = None,
        auto_reset: bool = True,
        render_kwargs: Optional[Dict[str, Any]] = None
    ) -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/environments/PyEnvironment

Note that by default a TimeLimit wrapper is used to limit episode lengths
to the default benchmarks defined by the registered environments.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `gym_env` | An instance of OpenAI gym environment. |
| `discount` | Discount to use for the environment. |
| `max_episode_steps` | Used to create a TimeLimitWrapper. No limit is applied if set to None or 0. Usually set to `gym_spec.max_episode_steps` in `load`. |
| `gym_env_wrappers` | Iterable with references to wrapper classes to use directly on the gym environment. |
| `time_limit_wrapper` | Wrapper that accepts (env, max_episode_steps) params to enforce a TimeLimit. Usuaully this should be left as the default, wrappers.TimeLimit. |
| `env_wrappers` | Iterable with references to wrapper classes to use on the gym_wrapped environment. |
| `spec_dtype_map` | A dict that maps gym specs to tf dtypes to use as the default dtype for the tensors. An easy way how to configure a custom mapping through Gin is to define a gin-configurable function that returns desired mapping and call it in your Gin config file, for example: `suite_gym.load.spec_dtype_map = @get_custom_mapping()`. |
| `auto_reset` | If True (default), reset the environment automatically after a terminal state is reached. |
| `render_kwargs` | Optional `dict` of keywoard arguments for rendering. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A PyEnvironment instance. ||

<br />