input.data.new create a tensor whose type is same as input.data, and also you can create a variable in a normal way such as Variable(torch.zeros(*state_shape)), but in order to keep the tensor type consistent with inputs, you need to cast to the type of inputs.  with type_as or type manually