My training loop is as follows:
When I add the line ----- evaluation.make_sentence_one_by_one(inputs) ---- which has nothing to do with the model or torch, I am facing nan in training after some epochs. Is there a problem when I call a function from another file inside torch_no_grad()?
for epoch in epochs:
     encoder.train()
     decoder.train()
     for index, sample in enumerate(datalodader_train):
          encoder_optimizer.zero_grad()
          decoder_optimizer.zero_grad()
          #training
          loss.backward()
          encoder_optimizer.step()
          decoder_optimizer.step()

          with torch.no_grad():
          recommender_encoder.eval()
          recommender_decoder.eval()
               for index, sample in enumerate(dataloader_test):
               #testing
               -----  evaluation.make_sentence_one_by_one(inputs)