the validation seems works like the below Code.
In validation without backward(), optimizer.step(), and optimizer.zero_grad() that I put in training?
   
    valid_loss_d = 0.0
    valid_loss_g = 0.0

    
    G.eval()
    D.eval()
    d_val_losses, g_val_losses = [], []
    
    #with torch.no_grad():
    for i, (data, _,_) in enumerate(valid_dataloader):
            data = data.to(device, dtype= torch.float32)

            z = torch.cuda.FloatTensor(np.random.normal(0, 1, (data.shape[0], latent_dim))).to(device)
            
            fake_imgs = G(z)
            
            real_validity = D(data)
            fake_validity = D(fake_imgs.detach())
            
            # Gradient penalty
            gradient_penalty = compute_gradient_penalty(D, data.data, fake_imgs.data)
            
            # Adversarial loss
            val_d_loss = -torch.mean(real_validity) + torch.mean(fake_validity) +lambda_gp *  gradient_penalty
            if i % n_critic == 0:
                # -----------------
                #  Train Generator
                # -----------------
                
                fake_imgs = G(z)
                fake_validity = D(fake_imgs)

                val_g_loss = -torch.mean(fake_validity)
                
                d_val_losses.append(val_d_loss.item())
                g_val_losses.append(val_g_loss.item())
                
                valid_loss_d+= val_d_loss.item() 
                valid_loss_g+= val_g_loss.item() 
            
            

    print(f"[G_Train_Loss: {g_running_loss / len(train_dataloader)}] "
            f"[D_Train_Loss: {d_running_loss / len(train_dataloader)}]"
            f"[G_Val_Loss: {valid_loss_g / len(valid_dataloader)}]"
            f"[D_Val_Loss: {valid_loss_d / len(valid_dataloader)}]"
           )

                
    val_total_g_losses.append(valid_loss_g/len(valid_dataloader))
    val_total_d_losses.append(valid_loss_d/len(valid_dataloader))
    
    
    if  min_valid_loss_g > valid_loss_g :
            print(f'G_Val_Loss_Decreased({min_valid_loss_g:.6f}--->{valid_loss_g:.6f})\t Saving The Model')
            min_valid_loss_g = valid_loss_g
            
            torch.save(G.state_dict(), f"./generator.pth")
            
    elif min_valid_loss_d > valid_loss_d :
        print( f'D_Val_Loss_Decreased({min_valid_loss_d:.6f}--->{valid_loss_d:.6f})\t Saving The Model')
        min_valid_loss_d = valid_loss_d
        torch.save(D.state_dict(), f"./discriminator.pth")

    else:
        print('None')