code: def dump_result(
      is_na_model,
      args,
      vocoder,
      sample_id,
      text,
      attn,
      eos_prob,
      feat_pred,
      wave_pred,
      feat_targ,
      wave_targ,
  ):
      sample_rate = args.output_sample_rate
      out_root = Path(args.results_path)
      if args.dump_features:
          feat_dir = out_root / "feat"
          feat_dir.mkdir(exist_ok=True, parents=True)
          np.save(feat_dir / f"{sample_id}.npy", feat_pred)
          if args.dump_target:
              feat_tgt_dir = out_root / "feat_tgt"
              feat_tgt_dir.mkdir(exist_ok=True, parents=True)
              np.save(feat_tgt_dir / f"{sample_id}.npy", feat_targ)
      if args.dump_attentions:
          attn_dir = out_root / "attn"
          attn_dir.mkdir(exist_ok=True, parents=True)
          np.save(attn_dir / f"{sample_id}.npy", attn.numpy())
      if args.dump_eos_probs and not is_na_model:
          eos_dir = out_root / "eos"
          eos_dir.mkdir(exist_ok=True, parents=True)
          np.save(eos_dir / f"{sample_id}.npy", eos_prob)
  
      if args.dump_plots:
          images = [feat_pred.T] if is_na_model else [feat_pred.T, attn]
          names = ["output"] if is_na_model else ["output", "alignment"]
          if feat_targ is not None:
              images = [feat_targ.T] + images
              names = [f"target (idx={sample_id})"] + names
          if is_na_model:
              plot_tts_output(
                  images, names, attn, "alignment", suptitle=text
              )
          else:
              plot_tts_output(
                  images, names, eos_prob, "eos prob", suptitle=text
              )
          plot_dir = out_root / "plot"
          plot_dir.mkdir(exist_ok=True, parents=True)
          plt.savefig(plot_dir / f"{sample_id}.png")
          plt.close()
  
      if args.dump_waveforms:
          ext = args.audio_format
          if wave_pred is not None:
              wav_dir = out_root / f"{ext}_{sample_rate}hz_{vocoder}"
              wav_dir.mkdir(exist_ok=True, parents=True)
              sf.write(
                  wav_dir / f"{sample_id}.{ext}", wave_pred, sample_rate
              )
          if args.dump_target and wave_targ is not None:
              wav_tgt_dir = (
                  out_root / f"{ext}_{sample_rate}hz_{vocoder}_tgt"
              )
              wav_tgt_dir.mkdir(exist_ok=True, parents=True)
              sf.write(
                  wav_tgt_dir / f"{sample_id}.{ext}",
                  wave_targ,
                  sample_rate,
              )
  
file_path: fairseq/examples/speech_synthesis/generate_waveform.py
imports: import ast
  import logging
  import matplotlib.pyplot
  import numpy
  from pathlib import Path
  import soundfile
  import sys
  import torch
  import torchaudio
  from fairseq import checkpoint_utils, options, tasks, utils
  from fairseq.logging import progress_bar
  from fairseq.tasks.text_to_speech import plot_tts_output
  from fairseq.data.audio.text_to_speech_dataset import TextToSpeechDataset
label_desc: Use image node_id 3 for calling a global function with example usage: dump_result(is_na_model, args, vocoder, sample_id, text, attn, eos_prob, feat_pred, wave_pred, feat_targ, wave_targ) without return types