class_docstr: The Brain implementation for Tacotron2
class_docstr_tok: ["The","Brain","implementation","for","Tacotron2"]
docstr: Remembers samples of spectrograms and the batch for logging purposes
  
  Arguments
  ---------
  batch: tuple
      a training batch
  predictions: tuple
      predictions (raw output of the Tacotron model)
docstr_tok: ["Remembers","samples","of","spectrograms","and","the","batch","for","logging","purposes","Arguments","--","--","--","--","-","batch",":","tuple","a","training","batch","predictions",":","tuple","predictions","(","raw","output","of","the","Tacotron","model",")"]
code: def _remember_sample(self, batch, predictions):
      """Remembers samples of spectrograms and the batch for logging purposes
  
      Arguments
      ---------
      batch: tuple
          a training batch
      predictions: tuple
          predictions (raw output of the Tacotron model)
      """
      inputs, targets, num_items, labels, wavs = batch
      text_padded, input_lengths, _, max_len, output_lengths = inputs
      mel_target, _ = targets
      mel_out, mel_out_postnet, gate_out, alignments = predictions
      alignments_max = (
          alignments[0]
          .max(dim=-1)
          .values.max(dim=-1)
          .values.unsqueeze(-1)
          .unsqueeze(-1)
      )
      alignments_output = (
          alignments[0].T.flip(dims=(1,)) / alignments_max
      )
      self.hparams.progress_sample_logger.remember(
          target=self._get_spectrogram_sample(mel_target),
          output=self._get_spectrogram_sample(mel_out),
          output_postnet=self._get_spectrogram_sample(mel_out_postnet),
          alignments=alignments_output,
          raw_batch=self.hparams.progress_sample_logger.get_batch_sample(
              {
                  "text_padded": text_padded,
                  "input_lengths": input_lengths,
                  "mel_target": mel_target,
                  "mel_out": mel_out,
                  "mel_out_postnet": mel_out_postnet,
                  "max_len": max_len,
                  "output_lengths": output_lengths,
                  "gate_out": gate_out,
                  "alignments": alignments,
                  "labels": labels,
                  "wavs": wavs,
              }
          ),
      )
  
file_path: speechbrain/recipes/LJSpeech/TTS/tacotron2/train.py
imports: import torch
  import speechbrain
  import sys
  import logging
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.text_to_sequence import text_to_sequence
  from speechbrain.utils.data_utils import scalarize
label_desc: Use image node_id 6 for calling the Tacotron2Brain obj's underlying member method code with example usage: obj._remember_sample(batch, predictions) without return types