How to declare a scalar as a parameter in pytorch?
I am new to pytorch. I want to know how to declare a scalar as a parameter. I am wondering what's the difference between the following two ways?

x = torch.randn(1,1, requires_grad=True)


and

tensor = torch.randn(1,1)
x = Variable(tensor, requires_grad=True)


As per the pytorch official documentation here,

The Variable API has been deprecated: Variables are no longer necessary to use autograd with tensors. Autograd automatically supports Tensors with requires_grad set to True. 


Variable(tensor) and Variable(tensor, requires_grad) still work as expected, but they return Tensors instead of Variables.
var.data is the same thing as tensor.data.
Methods such as var.backward(), var.detach(), var.register_hook() now work on tensors with the same method names.


In addition, one can now create tensors with requires_grad=True using factory methods such as torch.randn(), torch.zeros(), torch.ones(), and others like the following:

autograd_tensor = torch.randn((2, 3, 4), requires_grad=True)

