astensors¶
- astensors(*values: Any, conversion: Callable[[Any], Tensor] | None = None) tuple[Tensor, ...] | Tensor[source]¶
Converts inputs into tensors.
If any value is a tensor, it will be used as a reference and non-tensor inputs will be converted using
scalar(). If there are no tensors, then all elements will be converted into tensors usingconversion. When determining a reference, the leftmost tensor will be used.- Parameters:
*values (Any) – values to convert into tensors
conversion (Callable[[Any], torch.Tensor] | None) – method to convert values if none are tensors, the default if unspecified. Defaults to
None.
- Returns:
converted values.
- Return type:
tuple[torch.Tensor, …] | torch.Tensor