This is the code:
n_epochs=6
print_every=1
val_loss_min=np.Inf
for epoch in range(n_epochs):
  train_loss=0
  model.train()
  for iteration,(Xstage1,X_batch) in enumerate(Train_Loader):
    print('Iteration:',iteration,'started')
    torch.cuda.synchronize()
    strat_iteration=datetime.now()
    optimizer.zero_grad()
    output=model(Xstage1.to(device))
    loss=criterion(output,X_batch.to(device))
    retain_graph=True
    loss.backward(retain_graph=True)
    optimizer.step()
    train_loss+=loss.item()*X_batch.shape[0]
    torch.cuda.synchronize()
    end_iteration = datetime.now() 
    print('Iteration stopped.')
    print('Iteration time:',end_iteration-strat_iteration)
    if iteration % print_every==0:
      is_training=model.training
      val_loss=0
      model.eval()
      for (Xstage1_valid,X_valid_batch) in Valid_Loader:
        output=model(Xstage1_valid.to(device))
        loss=criterion(output,X_valid_batch.to(device))
        val_loss+=loss.item()*data.shape[0]
      val_loss=val_loss/len(Valid_Loader.sampler)
      if val_loss<=val_loss_min:
        print('\tValidation loss decreased ({:.6f}-->{:.6f}). Saving Model...'.format(val_loss_min,val_loss))
        torch.save(model.state_dict(),'/content/drive/My Drive/dataset/model_second_step.pt')
        val_loss_min=val_loss
      model.train(mode=is_training)   
  train_loss=train_loss/len(Train_Loader.sampler)
  print('Epoch: {} \tTraining loss:{:.6f}'.format(epoch+1,train_loss))
end_time = datetime.now()
print('Duration: {}'.format(end_time - start_time))


and the complete output is:
Iteration: 0 started
Iteration stopped.
Iteration time: 1:04:42.598970
	Validation loss decreased (inf-->0.008777). Saving Model...
Iteration: 1 started
Iteration stopped.
Iteration time: 1:04:23.584298
	Validation loss decreased (0.008777-->0.008767). Saving Model...
Iteration: 2 started
Iteration stopped.
Iteration time: 1:05:28.936429
	Validation loss decreased (0.008767-->0.008762). Saving Model...
Iteration: 3 started
Iteration stopped.
Iteration time: 1:03:29.209401
	Validation loss decreased (0.008762-->0.008758). Saving Model...
Iteration: 4 started
Iteration stopped.
Iteration time: 1:03:13.451551
	Validation loss decreased (0.008758-->0.008754). Saving Model...
Iteration: 5 started
Iteration stopped.
Iteration time: 1:03:05.595077
	Validation loss decreased (0.008754-->0.008751). Saving Model...
Iteration: 6 started
Iteration stopped.
Iteration time: 1:03:31.586236
	Validation loss decreased (0.008751-->0.008749). Saving Model...
Iteration: 7 started
Iteration stopped.
Iteration time: 1:05:06.575140
Iteration: 8 started