class_docstr: Generator for logging Audio Codec model outputs.
docstr: Generate audio artifacts.
  
  Args:
      model: callable model, outputs (audio_pred, audio_pred_len)
      dataset_names: list of dataset names for the examples in audio batch
      audio_ids: list of IDs for the examples in audio batch
      audio: tensor of input audio signals, shape (B, T)
      audio_len: tensor of lengths for each example in the batch, shape (B,)
      save_input: if True, save input audio signals
docstr_tok: ["Generate","audio","artifacts",".","Args",":","model",":","callable","model",",","outputs","(","audio_pred",",","audio_pred_len",")","dataset_names",":","list","of","dataset","names","for","the","examples","in","audio","batch","audio_ids",":","list","of","IDs","for","the","examples","in","audio","batch","audio",":","tensor","of","input","audio","signals",",","shape","(","B",",","T",")","audio_len",":","tensor","of","lengths","for","each","example","in","the","batch",",","shape","(","B",",",")","save_input",":","if","True",",","save","input","audio","signals"]
code: def _generate_audio(
      self,
      model: LightningModule,
      dataset_names: List[str],
      audio_ids: List[str],
      audio: Tensor,
      audio_len: Tensor,
      save_input: bool = False,
  ):
      """Generate audio artifacts.
  
      Args:
          model: callable model, outputs (audio_pred, audio_pred_len)
          dataset_names: list of dataset names for the examples in audio batch
          audio_ids: list of IDs for the examples in audio batch
          audio: tensor of input audio signals, shape (B, T)
          audio_len: tensor of lengths for each example in the batch, shape (B,)
          save_input: if True, save input audio signals
      """
      if not self.log_audio:
          return []
  
      with torch.no_grad():
          # [B, T]
          audio_pred, audio_pred_len = model(
              audio=audio, audio_len=audio_len
          )
  
      audio_artifacts = []
      # Log output audio
      for i, (dataset_name, audio_id) in enumerate(
          zip(dataset_names, audio_ids)
      ):
          audio_pred_path = Path(
              f"{dataset_name}/{audio_id}_audio_out.wav"
          )
          audio_pred_i = (
              audio_pred[i, : audio_pred_len[i]].cpu().numpy()
          )
          audio_artifact = AudioArtifact(
              id=f"audio_out_{audio_id}",
              data=audio_pred_i,
              filepath=audio_pred_path,
              sample_rate=model.sample_rate,
          )
          audio_artifacts.append(audio_artifact)
  
      if save_input:
          # save input audio
          for i, (dataset_name, audio_id) in enumerate(
              zip(dataset_names, audio_ids)
          ):
              audio_in_path = Path(
                  f"{dataset_name}/{audio_id}_audio_in.wav"
              )
              audio_in_i = audio[i, : audio_len[i]].cpu().numpy()
              audio_artifact = AudioArtifact(
                  id=f"audio_in_{audio_id}",
                  data=audio_in_i,
                  filepath=audio_in_path,
                  sample_rate=model.sample_rate,
              )
              audio_artifacts.append(audio_artifact)
  
      return audio_artifacts
  
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 the AudioCodecArtifactGenerator obj's underlying member method code with example usage: obj._generate_audio(model, dataset_names, audio_ids, audio, audio_len, save_input) and returns: audio_artifacts, list