Hello It seems you are getting the error because the argument to from_numpy function is a single value rather than array.
In numpy, there is difference between np.array(1) and np.array([1]) and both are completely different data types.
Try torch.from_numpy(np.asarray(x)).