
    h&	                    "   S r SSKJr  SSKrSSKJr  SSKrSSKr	SSK
Jr  SSKJrJr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)zLHelper functions and wrapper class for converting between PyTorch and NumPy.    )annotationsN)Union)DependencyNotInstalled)ArrayConversionarray_conversionmodule_namespacezcTorch is not installed therefore cannot call `torch_to_numpy`, run `pip install "gymnasium[torch]"`)NumpyToTorchtorch_to_numpynumpy_to_torchDevice)xpc                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )r	   %   a  Wraps a NumPy-based environment such 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.NumpyToTorch`.

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

Example:
    >>> import torch
    >>> import gymnasium as gym
    >>> env = gym.make("CartPole-v1")
    >>> env = NumpyToTorch(env)
    >>> obs, _ = env.reset(seed=123)
    >>> type(obs)
    <class 'torch.Tensor'>
    >>> action = torch.tensor(env.action_space.sample())
    >>> obs, reward, terminated, truncated, info = env.step(action)
    >>> type(obs)
    <class 'torch.Tensor'>
    >>> type(reward)
    <class 'float'>
    >>> type(terminated)
    <class 'bool'>
    >>> type(truncated)
    <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 NumPy-based environment to wrap
    device: The device the torch Tensors should be moved to
)envenv_xp	target_xptarget_deviceN)super__init__nptorchdevice)selfr   r   	__class__s      [/home/james-whalen/.local/lib/python3.13/site-packages/gymnasium/wrappers/numpy_to_torch.pyr   NumpyToTorch.__init__E   s      	SuFS%+    )r   )N)r   zgym.Envr   zDevice | None)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__)r   s   @r   r	   r	   %   s    >	, 	,r   r	   )r#   
__future__r   	functoolstypingr   numpyr   	gymnasiumgymgymnasium.errorr   #gymnasium.wrappers.array_conversionr   r   r   r   strr   r   ImportError__all__partialr
   r   r	    r   r   <module>r3      s    R "     2 3$%F I ""#38H8LM""#38H8OP),? ),  
 m s   A? ?B