code: def compute_error_rates(
      outputs, targets, decoder, language_model, metric
  ):
      output = outputs.transpose(0, 1).to("cpu")
      output = decoder(output)
  
      # Compute CER
  
      output = language_model.decode(output.tolist())
      target = language_model.decode(targets.tolist())
  
      print_length = 20
      for i in range(2):
          # Print a few examples
          output_print = output[i].ljust(print_length)[:print_length]
          target_print = target[i].ljust(print_length)[:print_length]
          logging.info(
              "Target: %s    Output: %s", target_print, output_print
          )
  
      cers = [edit_distance(t, o) for t, o in zip(target, output)]
      cers = sum(cers)
      n = sum(len(t) for t in target)
      metric["batch char error"] = cers
      metric["batch char total"] = n
      metric["batch char error rate"] = cers / n
      metric["epoch char error"] += cers
      metric["epoch char total"] += n
      metric["epoch char error rate"] = (
          metric["epoch char error"] / metric["epoch char total"]
      )
  
      # Compute WER
  
      output = [o.split(language_model.char_space) for o in output]
      target = [t.split(language_model.char_space) for t in target]
  
      wers = [edit_distance(t, o) for t, o in zip(target, output)]
      wers = sum(wers)
      n = sum(len(t) for t in target)
      metric["batch word error"] = wers
      metric["batch word total"] = n
      metric["batch word error rate"] = wers / n
      metric["epoch word error"] += wers
      metric["epoch word total"] += n
      metric["epoch word error rate"] = (
          metric["epoch word error"] / metric["epoch word total"]
      )
  
imports: import argparse
  import logging
  import os
  import string
  from datetime import datetime
  from time import time
  import torch
  import torchaudio
  from ctc_decoders import GreedyDecoder
  from datasets import collate_factory, split_process_librispeech
  from languagemodels import LanguageModel
  from torch.optim import Adadelta, Adam, AdamW, SGD
  from torch.optim.lr_scheduler import ExponentialLR, ReduceLROnPlateau
  from torch.utils.data import DataLoader
  from torchaudio.functional import edit_distance
  from torchaudio.models.wav2letter import Wav2Letter
  from transforms import Normalize, UnsqueezeFirst
  from utils import count_parameters, MetricLogger, save_checkpoint
label_desc: Use image node_id 4 for calling a global function with example usage: compute_error_rates(outputs, targets, decoder, language_model, metric) without return types