class_docstr: FastPitch based model that can synthesize mel spectrograms from content and speaker embeddings
  obtained from SSLDisentangler. This model can be used for voice conversion by swapping the speaker embedding 
  of a given source utterance, with the speaker embedding of a target speaker.
class_docstr_tok: ["FastPitch","based","model","that","can","synthesize","mel","spectrograms","from","content","and","speaker","embeddings","obtained","from","SSLDisentangler",".","This","model","can","be","used","for","voice","conversion","by","swapping","the","speaker","embedding","of","a","given","source","utterance",",","with","the","speaker","embedding","of","a","target","speaker","."]
code: def on_validation_epoch_end(self, outputs):
      collect = lambda key: torch.stack(
          [x[key] for x in outputs]
      ).mean()
      val_loss = collect("val_loss")
      mel_loss = collect("mel_loss")
  
      self.log("v_loss", val_loss)
      self.log("v_mel_loss", mel_loss)
  
      if self.pitch_conditioning:
          pitch_loss = collect("pitch_loss")
          self.log("v_pitch_loss", pitch_loss)
  
      single_output = outputs[0]
      spec_target = single_output["mel_target"]
      spec_predict = single_output["mel_pred"]
      spec_len = single_output["spec_len"]
      pitch_target = single_output["pitch_target"]
      pitch_pred = single_output["pitch_pred"]
  
      if isinstance(self.logger, TensorBoardLogger):
          _rand_idx = random.randint(0, spec_target.shape[0] - 1)
          self.tb_logger.add_image(
              "val_mel_target",
              plot_spectrogram_to_numpy(
                  spec_target[_rand_idx].data.cpu().float().numpy()
              ),
              self.global_step,
              dataformats="HWC",
          )
          spec_predict = (
              spec_predict[_rand_idx].data.cpu().float().numpy()
          )
          self.tb_logger.add_image(
              "val_mel_predicted",
              plot_spectrogram_to_numpy(spec_predict),
              self.global_step,
              dataformats="HWC",
          )
  
          if self.pitch_conditioning:
              _pitch_pred = pitch_pred[_rand_idx].data.cpu().numpy()
              _pitch_target = pitch_target[_rand_idx].data.cpu().numpy()
  
              self.tb_logger.add_image(
                  "val_pitch",
                  plot_multipitch_to_numpy(_pitch_target, _pitch_pred),
                  self.global_step,
                  dataformats="HWC",
              )
  
          _spec_len = spec_len[_rand_idx].data.cpu().item()
          wav_vocoded = self.vocode_spectrogram(
              spec_target[_rand_idx]
              .data.cpu()
              .float()
              .numpy()[:, :_spec_len]
          )
          self.tb_logger.add_audio(
              "Real audio", wav_vocoded[0], self.global_step, 22050
          )
  
          wav_vocoded = self.vocode_spectrogram(
              spec_predict[:, :_spec_len]
          )
          self.tb_logger.add_audio(
              "Generated Audio", wav_vocoded[0], self.global_step, 22050
          )
          self.log_train_images = True
  
imports: import random
  from typing import Iterable
  import torch
  from hydra.utils import instantiate
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from pytorch_lightning.loggers import TensorBoardLogger
  from nemo.collections.tts.losses.fastpitchloss import DurationLoss, MelLoss, PitchLoss
  from nemo.collections.tts.modules.fastpitch import FastPitchSSLModule, average_features
  from nemo.collections.tts.modules.transformer import mask_from_lens
  from nemo.collections.tts.parts.utils.helpers import plot_multipitch_to_numpy, plot_spectrogram_to_numpy
  from nemo.core.classes import ModelPT
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging, model_utils
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 8 for calling the FastPitchModel_SSL obj's underlying member method code with example usage: obj.on_validation_epoch_end(outputs) without return types