Because my code is in the class method and after two ifs, it looks this way:
        if self.is_cuda:
            states = (torch.autograd.Variable(
                torch.zeros(self.model.num_layers, batch_size,
                            self.model.hidden_size)).cuda(),
                      torch.autograd.Variable(
                torch.zeros(self.model.num_layers, batch_size,
                            self.model.hidden_size)).cuda())
            inputs = torch.autograd.Variable(
                torch.from_numpy(context)).cuda()
        else:
            states = (torch.autograd.Variable(
                torch.zeros(self.model.num_layers, batch_size,
                            self.model.hidden_size)),
                      torch.autograd.Variable(
                torch.zeros(self.model.num_layers, batch_size,
                            self.model.hidden_size)))

which I find really awful. How can I refactor it to more compact look?
EDIT: I am initializing states for LSTMs for language models