docstr: Validate the torchscript consistency of a Decoder.
code: def test_decoder_inference_output_shape(self, n_batch):
      r"""Validate the torchscript consistency of a Decoder."""
      n_mels = 80
      n_seq = 200
      encoder_embedding_dim = 256
      decoder_max_step = 300  # make inference more efficient
      gate_threshold = (
          0.505  # if set to 0.5, the model will only run one step
      )
  
      model = _get_decoder_model(
          n_mels=n_mels,
          encoder_embedding_dim=encoder_embedding_dim,
          decoder_max_step=decoder_max_step,
          gate_threshold=gate_threshold,
      )
      model = model.to(self.device).eval()
  
      memory = torch.rand(
          n_batch,
          n_seq,
          encoder_embedding_dim,
          dtype=self.dtype,
          device=self.device,
      )
      memory_lengths = torch.ones(
          n_batch, dtype=torch.int32, device=self.device
      )
  
      (
          mel_specgram,
          mel_specgram_lengths,
          gate_outputs,
          alignments,
      ) = model.infer(memory, memory_lengths)
  
      assert len(mel_specgram.size()) == 3
      assert mel_specgram.size()[:-1] == (
          n_batch,
          n_mels,
      )
      assert mel_specgram.size()[2] == mel_specgram_lengths.max().item()
      assert len(mel_specgram_lengths.size()) == 1
      assert mel_specgram_lengths.size()[0] == n_batch
      assert mel_specgram_lengths.max().item() <= model.decoder_max_step
      assert len(gate_outputs.size()) == 2
      assert gate_outputs.size()[0] == n_batch
      assert gate_outputs.size()[1] == mel_specgram_lengths.max().item()
      assert len(alignments.size()) == 2
      assert alignments.size()[0] == n_seq
      assert (
          alignments.size()[1]
          == mel_specgram_lengths.max().item() * n_batch
      )
  
imports: from typing import Tuple
  import torch
  from parameterized import parameterized
  from torch import Tensor
  from torchaudio.models import Tacotron2
  from torchaudio.models.tacotron2 import _Decoder, _Encoder
  from torchaudio_unittest.common_utils import skipIfPy310, TestBaseMixin, torch_script
label_desc: Use image node_id 4 for calling the Tacotron2DecoderTests obj's underlying member method code with example usage: obj.test_decoder_inference_output_shape(n_batch) without return types