to do something like this in pytorch you would just do something like:
class Model(torch.nn.Module):
    def __init__(self, hidden_size):
        super(Model, self).__init__()
        self.lstm = nn.LSTMCell(1, hidden_size)
    def forward(self, inputs):  #and then in def forward:
        x, (hx, cx) = inputs
        x = x.view(x.size(0), -1)
        hx, cx = self.lstm(x, (hx, cx))
        x = hx
        return x, (hx, cx)

flag=True #to flag when at start of time series

if flag:   #beginning of sequence of data you want cell states from or when no longer need past cell state and starting fresh again
    cx = Variable(torch.zeros(1, hidden_size))
    hx = Variable(torch.zeros(1, hidden_size))
else:     #get cell state from last sequence batch to use as start of new batch
    cx = Variable(cx.data)
    hx = Variable(hx.data)

#input equals Variable of 1 by num of features at each time step

model = Model(hidden_size)
output, (hx, cx) = model((input, (hx, cx))