code: def main(args):
      torch.manual_seed(0)
      random.seed(0)
      np.random.seed(0)
  
      device = "cuda" if torch.cuda.is_available() else "cpu"
  
      if args.checkpoint_path is None and args.checkpoint_name is None:
          raise ValueError(
              "Either --checkpoint-path or --checkpoint-name must be specified."
          )
      elif (
          args.checkpoint_path is not None
          and args.checkpoint_name is not None
      ):
          raise ValueError(
              "Both --checkpoint-path and --checkpoint-name are specified, "
              "can only specify one."
          )
  
      n_symbols = len(get_symbol_list(args.text_preprocessor))
      text_preprocessor = partial(
          text_to_sequence,
          symbol_list=args.text_preprocessor,
          phonemizer=args.phonemizer,
          checkpoint=args.phonemizer_checkpoint,
          cmudict_root=args.cmudict_root,
      )
  
      if args.checkpoint_path is not None:
          tacotron2 = Tacotron2(n_symbol=n_symbols)
          tacotron2.load_state_dict(
              unwrap_distributed(
                  torch.load(args.checkpoint_path, map_location=device)[
                      "state_dict"
                  ]
              )
          )
          tacotron2 = tacotron2.to(device).eval()
      elif args.checkpoint_name is not None:
          tacotron2 = (
              pretrained_tacotron2(args.checkpoint_name)
              .to(device)
              .eval()
          )
  
          if n_symbols != tacotron2.n_symbols:
              raise ValueError(
                  "the number of symbols for text_preprocessor ({n_symbols}) "
                  "should match the number of symbols for the"
                  "pretrained tacotron2 ({tacotron2.n_symbols})."
              )
  
      if args.jit:
          tacotron2 = torch.jit.script(tacotron2)
  
      sequences, lengths = prepare_input_sequence(
          [args.input_text], text_processor=text_preprocessor
      )
      sequences, lengths = sequences.long().to(
          device
      ), lengths.long().to(device)
      with torch.no_grad():
          mel_specgram, _, _ = tacotron2.infer(sequences, lengths)
  
      if args.vocoder == "nvidia_waveglow":
          waveform = nvidia_waveglow_vocode(
              mel_specgram=mel_specgram, device=device, jit=args.jit
          )
  
      elif args.vocoder == "wavernn":
          waveform = wavernn_vocode(
              mel_specgram=mel_specgram,
              wavernn_checkpoint_name=args.wavernn_checkpoint_name,
              wavernn_loss=args.wavernn_loss,
              wavernn_no_mulaw=args.wavernn_no_mulaw,
              wavernn_no_batch_inference=args.wavernn_no_batch_inference,
              wavernn_batch_timesteps=args.wavernn_batch_timesteps,
              wavernn_batch_overlap=args.wavernn_batch_overlap,
              device=device,
              jit=args.jit,
          )
  
      elif args.vocoder == "griffin_lim":
          waveform = griffin_lim_vocode(
              mel_specgram=mel_specgram,
              n_fft=args.n_fft,
              n_mels=args.n_mels,
              sample_rate=args.sample_rate,
              mel_fmin=args.mel_fmin,
              mel_fmax=args.mel_fmax,
              jit=args.jit,
          )
  
      torchaudio.save(args.output_path, waveform, args.sample_rate)
  
file_path: audio/examples/pipeline_tacotron2/inference.py
imports: import argparse
  import os
  import random
  import sys
  from functools import partial
  import numpy
  import torch
  import torchaudio
  from datasets import InverseSpectralNormalization
  from text.text_preprocessing import available_phonemizers, available_symbol_set, get_symbol_list, text_to_sequence
  from torchaudio.models import Tacotron2, tacotron2
  from utils import prepare_input_sequence
label_desc: Use image node_id 6 for calling a global function with example usage: main(args) without return types