code: def main(args):
      logger.info(args)
  
      use_cuda = torch.cuda.is_available() and not args.cpu
  
      with open(args.vocoder_cfg) as f:
          vocoder_cfg = json.load(f)
      vocoder = CodeHiFiGANVocoder(args.vocoder, vocoder_cfg)
      if use_cuda:
          vocoder = vocoder.cuda()
  
      multispkr = vocoder.model.multispkr
      if multispkr:
          logger.info("multi-speaker vocoder")
          num_speakers = vocoder_cfg.get(
              "num_speakers", 200
          )  # following the default in codehifigan to set to 200
          assert (
              args.speaker_id < num_speakers
          ), f"invalid --speaker-id ({args.speaker_id}) with total #speakers = {num_speakers}"
  
      data = load_code(args.in_code_file)
      Path(args.results_path).mkdir(exist_ok=True, parents=True)
      for i, d in tqdm(enumerate(data), total=len(data)):
          x = {
              "code": torch.LongTensor(d).view(1, -1),
          }
          suffix = ""
          if multispkr:
              spk = (
                  random.randint(0, num_speakers - 1)
                  if args.speaker_id == -1
                  else args.speaker_id
              )
              suffix = f"_spk{spk}"
              x["spkr"] = torch.LongTensor([spk]).view(1, 1)
  
          x = utils.move_to_cuda(x) if use_cuda else x
          wav = vocoder(x, args.dur_prediction)
          dump_result(args, i, wav, suffix=suffix)
  
file_path: fairseq/examples/speech_to_speech/generate_waveform_from_code.py
imports: import argparse
  import json
  import logging
  from pathlib import Path
  import random
  import soundfile
  import torch
  from tqdm import tqdm
  from fairseq import utils
  from fairseq.models.text_to_speech.vocoder import CodeHiFiGANVocoder
label_desc: Use image node_id 3 for calling a global function with example usage: main(args) without return types