docstr: Performing gradient check on Tacotron2Loss.
docstr_tok: ["Performing","gradient","check","on","Tacotron2Loss","."]
code: def test_tacotron2_loss_gradcheck(self):
      """Performing gradient check on Tacotron2Loss."""
      (
          mel_specgram,
          mel_specgram_postnet,
          gate_out,
          truth_mel_specgram,
          truth_gate_out,
      ) = self._get_inputs()
  
      mel_specgram.requires_grad_(True)
      mel_specgram_postnet.requires_grad_(True)
      gate_out.requires_grad_(True)
  
      def _fn(
          mel_specgram,
          mel_specgram_postnet,
          gate_out,
          truth_mel_specgram,
          truth_gate_out,
      ):
          loss_fn = Tacotron2Loss()
          return loss_fn(
              (mel_specgram, mel_specgram_postnet, gate_out),
              (truth_mel_specgram, truth_gate_out),
          )
  
      gradcheck(
          _fn,
          (
              mel_specgram,
              mel_specgram_postnet,
              gate_out,
              truth_mel_specgram,
              truth_gate_out,
          ),
          fast_mode=True,
      )
      gradgradcheck(
          _fn,
          (
              mel_specgram,
              mel_specgram_postnet,
              gate_out,
              truth_mel_specgram,
              truth_gate_out,
          ),
          fast_mode=True,
      )
  
file_path: audio/test/torchaudio_unittest/example/tacotron2/tacotron2_loss_impl.py
imports: import torch
  from pipeline_tacotron2.loss import Tacotron2Loss
  from torch.autograd import gradcheck, gradgradcheck
  from torchaudio_unittest.common_utils import TestBaseMixin, torch_script
label_desc: Use image node_id 1 for calling the Tacotron2LossGradcheckTests obj's underlying member method code with example usage: obj.test_tacotron2_loss_gradcheck() and returns: loss_fn