class_docstr: HiFi-GAN model (https://arxiv.org/abs/2010.05646) that is used to generate audio from mel spectrogram.
class_docstr_tok: ["HiFi-GAN","model","(","https",":","\/\/arxiv.org\/abs\/2010.05646",")","that","is","used","to","generate","audio","from","mel","spectrogram","."]
code: def __init__(self, cfg: DictConfig, trainer: "Trainer" = None):
      # Convert to Hydra 1.0 compatible DictConfig
      cfg = model_utils.convert_model_config_to_dict_config(cfg)
      cfg = model_utils.maybe_update_config_version(cfg)
      self.ds_class = cfg.train_ds.dataset._target_
  
      super().__init__(cfg=cfg, trainer=trainer)
  
      self.audio_to_melspec_precessor = instantiate(cfg.preprocessor)
      # We use separate preprocessor for training, because we need to pass grads and remove pitch fmax limitation
      self.trg_melspec_fn = instantiate(
          cfg.preprocessor, highfreq=None, use_grads=True
      )
      self.generator = instantiate(cfg.generator)
      self.mpd = MultiPeriodDiscriminator(
          debug=cfg.debug if "debug" in cfg else False
      )
      self.msd = MultiScaleDiscriminator(
          debug=cfg.debug if "debug" in cfg else False
      )
      self.feature_loss = FeatureMatchingLoss()
      self.discriminator_loss = DiscriminatorLoss()
      self.generator_loss = GeneratorLoss()
  
      self.l1_factor = cfg.get("l1_loss_factor", 45)
  
      self.sample_rate = self._cfg.preprocessor.sample_rate
      self.stft_bias = None
  
      self.input_as_mel = False
      if self._train_dl:
          self.input_as_mel = (
              self._train_dl.dataset.load_precomputed_mel
          )
  
      self.log_audio = cfg.get("log_audio", False)
      self.log_config = cfg.get("log_config", None)
      self.lr_schedule_interval = None
  
      # Important: this property activates manual optimization.
      self.automatic_optimization = False
  
imports: import itertools
  from pathlib import Path
  import torch
  import torch.nn.functional
  from hydra.utils import instantiate
  from omegaconf import DictConfig, OmegaConf, open_dict
  from pytorch_lightning.loggers.wandb import WandbLogger
  from nemo.collections.tts.losses.hifigan_losses import DiscriminatorLoss, FeatureMatchingLoss, GeneratorLoss
  from nemo.collections.tts.models.base import Vocoder
  from nemo.collections.tts.modules.hifigan_modules import MultiPeriodDiscriminator, MultiScaleDiscriminator
  from nemo.collections.tts.parts.utils.callbacks import LoggingCallback
  from nemo.collections.tts.parts.utils.helpers import get_batch_size, get_num_workers, plot_spectrogram_to_numpy
  from nemo.core.classes import Exportable
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.neural_types.elements import AudioSignal, MelSpectrogramType
  from nemo.core.neural_types.neural_type import NeuralType
  from nemo.core.optim.lr_scheduler import compute_max_steps, prepare_lr_scheduler
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 1 to create a new HifiGanModel object from inherited base classes: Vocoder, Exportable with example: obj = HifiGanModel(cfg, trainer)