code: def test_parallel_wavegan_generator_and_discriminator(dict_g, dict_d):
      # setup
      batch_size = 4
      batch_length = 4096
      args_g = make_generator_args(**dict_g)
      args_d = make_discriminator_args(**dict_d)
      y = torch.randn(batch_size, 1, batch_length)
      c = torch.randn(
          batch_size,
          args_g["aux_channels"],
          batch_length
          // np.prod(args_g["upsample_params"]["upsample_scales"]),
      )
      model_g = ParallelWaveGANGenerator(**args_g)
      model_d = ParallelWaveGANDiscriminator(**args_d)
      gen_adv_criterion = GeneratorAdversarialLoss()
      dis_adv_criterion = DiscriminatorAdversarialLoss()
      optimizer_g = torch.optim.Adam(model_g.parameters())
      optimizer_d = torch.optim.Adam(model_d.parameters())
  
      # check generator trainable
      y_hat = model_g(c)
      p_hat = model_d(y_hat)
      loss_g = gen_adv_criterion(p_hat)
      optimizer_g.zero_grad()
      loss_g.backward()
      optimizer_g.step()
  
      # check discriminator trainable
      p = model_d(y)
      p_hat = model_d(y_hat.detach())
      real_loss, fake_loss = dis_adv_criterion(p_hat, p)
      loss_d = real_loss + fake_loss
      optimizer_d.zero_grad()
      loss_d.backward()
      optimizer_d.step()
  
file_path: espnet/test/espnet2/gan_tts/parallel_wavegan/test_parallel_wavegan.py
imports: import numpy
  import pytest
  import torch
  from espnet2.gan_tts.hifigan.loss import DiscriminatorAdversarialLoss, GeneratorAdversarialLoss
  from espnet2.gan_tts.parallel_wavegan import ParallelWaveGANDiscriminator, ParallelWaveGANGenerator
label_desc: Use image node_id 3 for calling a global function with example usage: test_parallel_wavegan_generator_and_discriminator(dict_g, dict_d) without return types