code: def main(args):
      dense_model_name = args.dense_model_name
      quantizer_name = "kmeans"
  
      # We can build a speech encoder module using names of pre-trained dense and quantizer models.
      # The call below will download appropriate checkpoints as needed behind the scenes
      encoder = SpeechEncoder.by_name(
          dense_model_name=dense_model_name,
          quantizer_model_name=quantizer_name,
          vocab_size=args.vocab_size,
          need_f0=False,
          deduplicate=True,
          f0_normalizer=None,
          f0_quantizer=None,
      ).cuda()
  
      # Alternatively, we can pass dense/quantizer models directly.
      # Here, we'll look up the same models as above, but generally those
      # could be any other models.
      dense_model = dispatch_dense_model(dense_model_name)
      quantizer_model = dispatch_quantizer(
          dense_model_name, quantizer_name, args.vocab_size
      )
  
      # .. and use them when initializing the encoder. Same constructor can be used to when we want
      # to use models other than pre-defined.
      encoder = SpeechEncoder(
          dense_model=dense_model,
          quantizer_model=quantizer_model,
          need_f0=False,
          deduplicate=True,
          f0_normalizer=None,
          f0_quantizer=None,
      ).cuda()
  
      # now let's load an audio example
      waveform, input_sample_rate = torchaudio.load(args.input)
      if waveform.ndim == 2:
          waveform = waveform.mean(dim=0)
  
      waveform = encoder.maybe_resample(waveform, input_sample_rate)
  
      # now and convert it in a stream of deduplicated units (as in GSLM)
      encoded = encoder(waveform.cuda())
      # encoded is a dict with keys ('dense', 'units', 'durations'). It can also contain 'f0' if SpeechEncoder
      # was initialized with need_f0=True flag.
      units = encoded[
          "units"
      ]  # tensor([71, 12, 57, 12, 57, 12, 57, 12, ...], device='cuda:0', dtype=torch.int32)
  
      # as with encoder, we can setup vocoder by specifying names of pretrained models
      # or by passing checkpoint paths directly. The dense/quantizer models are not invokes,
      # we just use their names as an index.
      vocoder = TacotronVocoder.by_name(
          dense_model_name,
          quantizer_name,
          args.vocab_size,
      ).cuda()
  
      # now we turn those units back into the audio.
      audio = vocoder(units)
  
      # save the audio
      torchaudio.save(
          args.output,
          audio.cpu().float().unsqueeze(0),
          vocoder.output_sample_rate,
      )
  
      uniform_bps, learned_bps = get_compression_rate(
          dense_model_name,
          units,
          waveform,
          args.vocab_size,
          encoder.expected_sample_rate,
      )
  
      print(
          f"Audio of length {round(waveform.size(0) / 16_000, 1)} seconds represented as {units.numel()} tokens"
      )
      print(
          f"\tAssuming uniform token distribution: {round(uniform_bps, 1)} bits per second"
      )
      print(
          f"\tAssuming unigram token distribution estimated on LL-6K train: {round(learned_bps, 1)} bits per second"
      )
  
imports: import torchaudio
  from textless import dispatch_dense_model, dispatch_quantizer
  from textless.data.speech_encoder import SpeechEncoder
  from textless.vocoders.tacotron2.vocoder import TacotronVocoder
label_desc: Use image node_id 3 for calling a global function with example usage: main(args) without return types