text: # flake8: noqa
  
  import glow.nn as gnn
  
  d_grads = gnn.get_grads(d_opt)
  g_grads = gnn.get_grads(g_opt)
  
  
  def step():
      with d_grads:
          d_err_real = criterion(d_net(real), real_label)
          d_grads.backward(d_err_real)
  
          fake = g_net(noise)
          d_err_fake = criterion(d_net(fake.detach()), fake_label)
          d_grads.backward(d_err_fake)
  
      with g_grads, gnn.eval_(d_net):
          g_err = criterion(d_net(fake), real_label)
          g_grads.backward(g_err)
  