code: def _load_vocoder(
      model_name: Optional[str],
      checkpoint_path: Optional[str],
      type: str,
  ):
      assert (model_name is None) != (
          checkpoint_path is None
      ), f"Must provide exactly one of vocoder model_name or checkpoint: ({model_name}, {checkpoint_path})"
  
      checkpoint_path = str(checkpoint_path)
      if type == "hifigan":
          from nemo.collections.tts.models import HifiGanModel
  
          model_type = HifiGanModel
      elif type == "univnet":
          from nemo.collections.tts.models import UnivNetModel
  
          model_type = UnivNetModel
      else:
          raise ValueError(f"Unknown vocoder type '{type}'")
  
      if model_name is not None:
          vocoder = model_type.from_pretrained(model_name)
      elif checkpoint_path.endswith(".nemo"):
          vocoder = model_type.restore_from(checkpoint_path)
      else:
          vocoder = model_type.load_from_checkpoint(checkpoint_path)
  
      return vocoder.eval()
  
imports: import os
  from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Dict, List, Optional, Tuple, Type
  import librosa
  import numpy
  import soundfile
  import torch
  from einops import rearrange
  from pytorch_lightning import Callback, LightningModule, Trainer
  from pytorch_lightning.loggers import TensorBoardLogger
  from pytorch_lightning.loggers.logger import Logger
  from pytorch_lightning.loggers.wandb import WandbLogger
  from torch import Tensor
  from nemo.collections.tts.parts.utils.helpers import create_plot
  from nemo.utils import logging
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 2 for calling a global function with example usage: _load_vocoder(model_name, checkpoint_path, type) and returns: vocoder