code: def run_inference(args):
      # get pretrained wav2vec2.0 model
      bundle = getattr(torchaudio.pipelines, args.model)
      model = bundle.get_model()
  
      # get decoder files
      files = download_pretrained_files("librispeech-4-gram")
  
      decoder = ctc_decoder(
          lexicon=files.lexicon,
          tokens=files.tokens,
          lm=files.lm,
          nbest=args.nbest,
          beam_size=args.beam_size,
          beam_size_token=args.beam_size_token,
          beam_threshold=args.beam_threshold,
          lm_weight=args.lm_weight,
          word_score=args.word_score,
          unk_score=args.unk_score,
          sil_score=args.sil_score,
          log_add=False,
      )
  
      dataset = torchaudio.datasets.LIBRISPEECH(
          args.librispeech_path, url=args.split, download=False
      )
  
      total_edit_distance = 0
      total_length = 0
      for idx, sample in enumerate(dataset):
          waveform, _, transcript, _, _, _ = sample
          transcript = transcript.strip().lower().strip()
  
          with torch.inference_mode():
              emission, _ = model(waveform)
          results = decoder(emission)
  
          total_edit_distance += torchaudio.functional.edit_distance(
              transcript.split(), results[0][0].words
          )
          total_length += len(transcript.split())
  
          if idx % 100 == 0:
              logger.info(
                  f"Processed elem {idx}; WER: {total_edit_distance / total_length}"
              )
      logger.info(f"Final WER: {total_edit_distance / total_length}")
  
file_path: audio/examples/asr/librispeech_ctc_decoder/inference.py
imports: import argparse
  import logging
  from typing import Optional
  import torch
  import torchaudio
  from torchaudio.models.decoder import ctc_decoder, download_pretrained_files
label_desc: Use image node_id 1 for calling a global function with example usage: run_inference(args) without return types