tfep.utils.misc.ensure_tensor_sequence
- tfep.utils.misc.ensure_tensor_sequence(x: str | int | float | Sequence, dtype=None) Tensor[source]
If x is a sequence, return it as a torch.Tensor without copying the memory (if possible).
- Parameters:
x (str, int, float, or Sequence) – The input. Sequences (that are not strings) are converted to
torch.Tensors.dtype (dtype or None, optional) – If set, forces the tensor to a data type.
- Returns:
converted_x – The input, eventually converted to a tensor.
- Return type:
str, int, float, or torch.Tensor