ray.rllib.utils.torch_utils.convert_to_torch_tensor(x: numpy.array | jnp.ndarray | tf.Tensor | torch.Tensor | dict | tuple, device: str | None = None)[source]#

Converts any struct to torch.Tensors.

x: Any (possibly nested) struct, the values in which will be

converted and returned as a new struct with all leaves converted to torch tensors.


A new struct with the same structure as x, but with all

values converted to torch Tensor types. This does not convert possibly nested elements that are None because torch has no representation for that.

Return type: