>>> import torch
>>> from torch.autograd import Variable
>>> a = torch.randn(2, 3)
>>> a_var = Variable(a, requires_grad=True)
>>> b = torch.randn(2, 3)
>>> b_var = Variable(b, requires_grad=True)
>>> a.requires_grad
False
>>> b.requires_grad
False
>>> a_var.requires_grad
True
>>> b_var.requires_grad
True
>>> c = torch.cat([a, b], 1)
>>> c.requires_grad
False
>>> c_var = torch.cat([a_var, b_var], 1)
>>> c_var.requires_grad
True

Note that :
Merging Tensor and Variable classes
torch.autograd.Variable and torch.Tensor are now the same class.
More precisely, torch.Tensor is capable of tracking history and behaves like the old Variable;
Variable wrapping continues to work as before but returns an object of type torch.Tensor.
This means that you don’t need the Variable wrapper everywhere in your code anymore.