class_docstr: T5-based grapheme-to-phoneme model.
docstr: Called at the end of validation to aggregate outputs (reduces across batches, not workers).
docstr_tok: ["Called","at","the","end","of","validation","to","aggregate","outputs","(","reduces","across","batches",",","not","workers",")","."]
code: def multi_validation_epoch_end(
      self, outputs, dataloader_idx=0, split="val"
  ):
      """
      Called at the end of validation to aggregate outputs (reduces across batches, not workers).
      """
      avg_loss = torch.stack(
          [x[f"{split}_loss"] for x in outputs]
      ).mean()
      self.log(f"{split}_loss", avg_loss, sync_dist=True)
  
      if split == "test":
          dataloader_name = self._test_names[dataloader_idx].upper()
      else:
          dataloader_name = self._validation_names[
              dataloader_idx
          ].upper()
  
      avg_per = sum([x["per"] for x in outputs]) / len(outputs)
      self.log(f"{split}_per", avg_per)
  
      # to save all PER values for each dataset in WANDB
      self.log(f"{split}_per_{dataloader_name}", avg_per)
  
      logging.info(
          f"PER: {round(avg_per * 100, 2)}% {dataloader_name}, {len(outputs)}examples"
      )
      return {"loss": avg_loss}
  
imports: from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Union
  import torch
  from hydra.utils import instantiate
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from transformers import AutoTokenizer, T5ForConditionalGeneration
  from nemo.collections.asr.metrics.wer import word_error_rate
  from nemo.collections.tts.g2p.data.t5 import T5G2PDataset
  from nemo.collections.tts.models.base import G2PModel
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.neural_types import LabelsType, LossType, MaskType, NeuralType, TokenIndex
  from nemo.utils import logging
label_desc: Use image node_id 11 for calling the T5G2PModel obj's underlying member method code with example usage: obj.multi_validation_epoch_end(outputs, dataloader_idx, split) and returns: dict