docstr: Train discriminator and generator adversarially
docstr_tok: ["Train","discriminator","and","generator","adversarially"]
code: def fit_batch(self, batch):
      """Train discriminator and generator adversarially"""
  
      batch = batch.to(self.device)
      y, _ = batch.sig
  
      outputs = self.compute_forward(batch, sb.core.Stage.TRAIN)
      (
          y_g_hat,
          scores_fake,
          feats_fake,
          scores_real,
          feats_real,
      ) = outputs
      # calculate discriminator loss with the latest updated generator
      loss_d = self.compute_objectives(
          outputs, batch, sb.core.Stage.TRAIN
      )["D_loss"]
      # First train the discriminator
      self.optimizer_d.zero_grad()
      loss_d.backward()
      self.optimizer_d.step()
  
      # calculate generator loss with the latest updated discriminator
      scores_fake, feats_fake = self.modules.discriminator(y_g_hat)
      scores_real, feats_real = self.modules.discriminator(y)
      outputs = (
          y_g_hat,
          scores_fake,
          feats_fake,
          scores_real,
          feats_real,
      )
      loss_g = self.compute_objectives(
          outputs, batch, sb.core.Stage.TRAIN
      )["G_loss"]
      # Then train the generator
      self.optimizer_g.zero_grad()
      loss_g.backward()
      self.optimizer_g.step()
  
      return loss_g.detach().cpu()
  
imports: import sys
  import torch
  import copy
  from hyperpyyaml import load_hyperpyyaml
  import speechbrain
  from speechbrain.utils.data_utils import scalarize
  import torchaudio
  import os
label_desc: Use image node_id 3 for calling the HifiGanBrain obj's underlying member method code with example usage: obj.fit_batch(batch) and returns: loss_g