torch.as_tensor
torch.as_tensor(data, dtype=None, device=None) -> Tensor
Converts "data" into a tensor, sharing data and preserving autograd
   history if possible.
If "data" is already a tensor with the requested dtype and device
   then "data" itself is returned, but if "data" is a tensor with a
   different dtype or device then it's copied as if using
   data.to(dtype=dtype, device=device).
If "data" is a NumPy array (an ndarray) with the same dtype and
   device then a tensor is constructed using "torch.from_numpy()".
See also:
 "torch.tensor()" never shares its data and creates a new "leaf
 tensor" (see Autograd mechanics).

Parameters:
      * data (array_like) -- Initial data for the tensor. Can be
        a list, tuple, NumPy "ndarray", scalar, and other types.
  * **dtype** ("torch.dtype", optional) -- the desired data type
    of returned tensor. Default: if "None", infers data type from
    "data".
