code: def compute_wer(dists, scores, total_len):
      """
      Sorts the candidates based on the scores and calculates the WER with the new top candidates.
  
      Args:
          dists: Tensor of the distances between the ground truth and the candidates with shape of [number of samples, beam size]
          scores: Tensor of the scores for candidates with shape of [number of samples, beam size]
          total_len: The total length of all samples
  
      Output:
          WER with the new scores
      """
      indices = scores.max(dim=1, keepdim=True)[1]
      wer = dists.gather(dim=1, index=indices).sum() / total_len
      wer = wer.item()
      return wer
  
imports: import contextlib
  import inspect
  import json
  from argparse import ArgumentParser
  import editdistance
  import matplotlib.pyplot
  import numpy
  import pandas
  import torch
  import tqdm
  from transformers import AutoModelForCausalLM
  from nemo.collections.nlp.models.language_modeling import TransformerLMModel
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_tokenizer
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling a global function with example usage: compute_wer(dists, scores, total_len) and returns: wer