Sure. I’ve done my best to clean up the code and paraphrase where I can. The actual code is really, really messy since the discriminator model is implemented in Tensorflow (don’t ask). Here’s the training loop:
criterion = nn.MSELoss()

for epoch in range(num_epochs):
  for i, training_batch in enumerate(training_samples):
    
    net.zero_grad()
    output = net(training_batch)

    # Reformat training batch for discriminator
    training_batch2 = training_batch.clone().detach().cpu().numpy()
	# Emitted code: format training_batch2 to fit into discriminator model

    # Run discriminator model with training batch
    # paraphrased code: output_pred_vals = discriminator(training_batch2)

    # Reformat model output for discriminator
    output2 = output.clone().detach().cpu().numpy()
    # Emitted code: format output2 to fit into discriminator model

    # Run discriminator model with training batch
    # paraphrased code: training_pred_vals = discriminator(output2)
    
    output_pred = torch.as_tensor(output_pred_vals).to(device, dtype=torch.float) 
    training_pred = torch.as_tensor(training_pred_vals).to(device, dtype=torch.float) 

    training_loss = criterion(output_pred, training_pred)

    training_loss.backward()
    optimizer.step()

    # print training loss, validation loss, etc.