
    hw                    L   S r SSKJr  SSKrSSKJr  SSKrSSKJ	r	  SSK
JrJrJr   SSKJr   SSKr\\\R(                  4   r/ S	Qr\R.                  " \\" \5      S
9r\R.                  " \\" \5      S
9r " S S\5      rg! \ a	    \	" S5      ef = f! \ a	    \	" S5      ef = f)zJHelper functions and wrapper class for converting between PyTorch and Jax.    )annotationsN)Union)DependencyNotInstalled)ArrayConversionarray_conversionmodule_namespacez]Jax is not installed therefore cannot call `torch_to_jax`, run `pip install "gymnasium[jax]"`zaTorch is not installed therefore cannot call `torch_to_jax`, run `pip install "gymnasium[torch]"`)
JaxToTorchjax_to_torchtorch_to_jaxDevice)xpc                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )r	   3   a  Wraps a Jax-based environment so that it can be interacted with PyTorch Tensors.

Actions must be provided as PyTorch Tensors and observations will be returned as PyTorch Tensors.
A vector version of the wrapper exists, :class:`gymnasium.wrappers.vector.JaxToTorch`.

Note:
    For ``rendered`` this is returned as a NumPy array not a pytorch Tensor.

Example:
    >>> import torch                                                # doctest: +SKIP
    >>> import gymnasium as gym                                     # doctest: +SKIP
    >>> env = gym.make("JaxEnv-vx")                                 # doctest: +SKIP
    >>> env = JaxtoTorch(env)                                       # doctest: +SKIP
    >>> obs, _ = env.reset(seed=123)                                # doctest: +SKIP
    >>> type(obs)                                                   # doctest: +SKIP
    <class 'torch.Tensor'>
    >>> action = torch.tensor(env.action_space.sample())            # doctest: +SKIP
    >>> obs, reward, terminated, truncated, info = env.step(action) # doctest: +SKIP
    >>> type(obs)                                                   # doctest: +SKIP
    <class 'torch.Tensor'>
    >>> type(reward)                                                # doctest: +SKIP
    <class 'float'>
    >>> type(terminated)                                            # doctest: +SKIP
    <class 'bool'>
    >>> type(truncated)                                             # doctest: +SKIP
    <class 'bool'>

Change logs:
 * v1.0.0 - Initially added
c                B   > [         TU ]  U[        [        US9  X l        g)zWrapper class to change inputs and outputs of environment to PyTorch tensors.

Args:
    env: The Jax-based environment to wrap
    device: The device the torch Tensors should be moved to
)envenv_xp	target_xptarget_deviceN)super__init__jnptorchdevice)selfr   r   	__class__s      Y/home/james-whalen/.local/lib/python3.13/site-packages/gymnasium/wrappers/jax_to_torch.pyr   JaxToTorch.__init__S   s"     	SVT &,    )r   )N)r   zgym.Envr   zDevice | None)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__)r   s   @r   r	   r	   3   s    >, ,r   r	   )r#   
__future__r   	functoolstypingr   	gymnasiumgymgymnasium.errorr   #gymnasium.wrappers.array_conversionr   r   r   	jax.numpynumpyr   ImportErrorr   strr   r   __all__partialr   r
   r	    r   r   <module>r4      s    Q "    2 3$%F C   !16Fs6KL  !16Fu6MN+, +,/  
 g   
 k s   B B BB#