class_docstr: UnivNet model (https://arxiv.org/abs/2106.07889) that is used to generate audio from mel spectrogram.
class_docstr_tok: ["UnivNet","model","(","https",":","\/\/arxiv.org\/abs\/2106.07889",")","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)
  
      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,
          n_mel_channels=cfg.preprocessor.nfilt,
          hop_length=cfg.preprocessor.n_window_stride,
      )
      self.mpd = MultiPeriodDiscriminator(
          cfg.discriminator.mpd,
          debug=cfg.debug if "debug" in cfg else False,
      )
      self.mrd = MultiResolutionDiscriminator(
          cfg.discriminator.mrd,
          debug=cfg.debug if "debug" in cfg else False,
      )
  
      self.discriminator_loss = DiscriminatorLoss()
      self.generator_loss = GeneratorLoss()
  
      # Reshape MRD resolutions hyperparameter and apply them to MRSTFT loss
      self.stft_resolutions = cfg.discriminator.mrd.resolutions
      self.fft_sizes = [res[0] for res in self.stft_resolutions]
      self.hop_sizes = [res[1] for res in self.stft_resolutions]
      self.win_lengths = [res[2] for res in self.stft_resolutions]
      self.mrstft_loss = MultiResolutionSTFTLoss(
          self.fft_sizes, self.hop_sizes, self.win_lengths
      )
      self.stft_lamb = cfg.stft_lamb
  
      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.automatic_optimization = False
  
imports: import itertools
  from typing import Dict
  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, GeneratorLoss
  from nemo.collections.tts.losses.stftlosses import MultiResolutionSTFTLoss
  from nemo.collections.tts.models.base import Vocoder
  from nemo.collections.tts.modules.univnet_modules import MultiPeriodDiscriminator, MultiResolutionDiscriminator
  from nemo.collections.tts.parts.utils.helpers import get_batch_size, get_num_workers, plot_spectrogram_to_numpy
  from nemo.core 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 UnivNetModel object from inherited base classes: Vocoder, Exportable with example: obj = UnivNetModel(cfg, trainer)