code: def tacotron2_log_to_tb_func(
      swriter,
      tensors,
      step,
      tag="train",
      log_images=False,
      log_images_freq=1,
      add_audio=True,
      griffin_lim_mag_scale=1024,
      griffin_lim_power=1.2,
      sr=22050,
      n_fft=1024,
      n_mels=80,
      fmax=8000,
  ):
      (
          _,
          spec_target,
          mel_postnet,
          gate,
          gate_target,
          alignments,
      ) = tensors
      if log_images and step % log_images_freq == 0:
          swriter.add_image(
              f"{tag}_alignment",
              plot_alignment_to_numpy(
                  alignments[0].data.cpu().numpy().T
              ),
              step,
              dataformats="HWC",
          )
          swriter.add_image(
              f"{tag}_mel_target",
              plot_spectrogram_to_numpy(
                  spec_target[0].data.cpu().numpy()
              ),
              step,
              dataformats="HWC",
          )
          swriter.add_image(
              f"{tag}_mel_predicted",
              plot_spectrogram_to_numpy(
                  mel_postnet[0].data.cpu().numpy()
              ),
              step,
              dataformats="HWC",
          )
          swriter.add_image(
              f"{tag}_gate",
              plot_gate_outputs_to_numpy(
                  gate_target[0].data.cpu().numpy(),
                  torch.sigmoid(gate[0]).data.cpu().numpy(),
              ),
              step,
              dataformats="HWC",
          )
  
          if add_audio:
              filterbank = librosa.filters.mel(
                  sr=sr, n_fft=n_fft, n_mels=n_mels, fmax=fmax
              )
              log_mel = mel_postnet[0].data.cpu().numpy().T
              mel = np.exp(log_mel)
              magnitude = (
                  np.dot(mel, filterbank) * griffin_lim_mag_scale
              )
              audio = griffin_lim(magnitude.T**griffin_lim_power)
              swriter.add_audio(
                  f"audio/{tag}_predicted",
                  audio / max(np.abs(audio)),
                  step,
                  sample_rate=sr,
              )
  
              log_mel = spec_target[0].data.cpu().numpy().T
              mel = np.exp(log_mel)
              magnitude = (
                  np.dot(mel, filterbank) * griffin_lim_mag_scale
              )
              audio = griffin_lim(magnitude.T**griffin_lim_power)
              swriter.add_audio(
                  f"audio/{tag}_target",
                  audio / max(np.abs(audio)),
                  step,
                  sample_rate=sr,
              )
  
imports: from enum import Enum
  from typing import Optional, Tuple
  import librosa
  import matplotlib.pylab
  import numpy
  import torch
  from einops import rearrange
  from numba import jit, prange
  from nemo.collections.tts.torch.tts_data_types import DATA_STR2DATA_CLASS, MAIN_DATA_TYPES, WithLens
  from nemo.utils import logging
  from nemo.utils.decorators import deprecated
label_desc: Use image node_id 13 for calling a global function with example usage: tacotron2_log_to_tb_func(swriter, tensors, step, tag, log_images, log_images_freq, add_audio, griffin_lim_mag_scale, griffin_lim_power, sr, n_fft, n_mels, fmax) without return types