I am using LSTM for PENN TreeBank problem.
Also I have one doubt that came across mind. For LSTMs, do I have to initialize hidden states in every loop or just at the start?
def train_loss(data, target, ht, ct):
    out, (ht, ct) = myModel(data, ht, ct)
    loss = F.cross_entropy(out, target)
    return loss, (ht, ct)

for epoch in range(EPOCHS):
    trainloss = 0.0
    
    t0 = time.time()
    for batch in train_loader:
        data, target = batch.text.t(), batch.target.t(), 
        loss, (ht, ct)  = train_loss(data, target.reshape(-1), ht, ct)

        grads = grad(loss, Ws)
        
        trainloss += loss
..........................