code: def train_discriminator(optimizer, data_real, data_fake):
      real_labels = make_labels(batch_size, 1)
      fake_labels = make_labels(batch_size, 0)
      optimizer.zero_grad()
      output_real = discriminator.forward(data_real)
      output_fake = discriminator.forward(data_fake)
      loss_real = (output_real * real_labels).mean()
      loss_fake = (output_fake * fake_labels).mean()
      loss_real.backward()
      loss_fake.backward()
      optimizer.step()
      return (loss_real + loss_fake).numpy()
  
file_path: tinygrad/examples/mnist_gan.py
imports: from pathlib import Path
  import numpy
  from tqdm import trange
  import torch
  from torchvision.utils import make_grid, save_image
  from tinygrad.nn.state import get_parameters
  from tinygrad.tensor import Tensor
  from tinygrad.helpers import getenv
  from tinygrad.nn import optim
  from extra.datasets import fetch_mnist
label_desc: Use image node_id 3 for calling a global function with example usage: train_discriminator(optimizer, data_real, data_fake) and returns: unknown