code: def calculate_and_print_report(
      wav_filenames, labels, decodings, losses, dataset_name
  ):
      r"""
      This routine will calculate and print a WER report.
      It'll compute the `mean` WER and create ``Sample`` objects of the ``report_count`` top lowest
      loss items from the provided WER results tuple (only items with WER!=0 and ordered by their WER).
      """
      samples = pmap(
          process_decode_result,
          zip(wav_filenames, labels, decodings, losses),
      )
  
      # Getting the WER and CER from the accumulated edit distances and lengths
      samples_wer, samples_cer = wer_cer_batch(samples)
  
      # Reversed because the worst WER with the best loss is to identify systemic issues, where the acoustic model is confident,
      # yet the result is completely off the mark. This can point to transcription errors and stuff like that.
      samples.sort(key=lambda s: s.loss, reverse=True)
  
      # Then order by ascending WER/CER
      if FLAGS.bytes_output_mode:
          samples.sort(key=lambda s: s.cer)
      else:
          samples.sort(key=lambda s: s.wer)
  
      # Print the report
      print_report(
          samples, losses, samples_wer, samples_cer, dataset_name
      )
  
      return samples
  
file_path: DeepSpeech/training/deepspeech_training/util/evaluate_tools.py
imports: from __future__ import absolute_import, division, print_function
  import json
  from multiprocessing.dummy import Pool
  import numpy
  from attrdict import AttrDict
  from .flags import FLAGS
  from .text import levenshtein
  from .io import open_remote
label_desc: Use image node_id 4 for calling a global function with example usage: calculate_and_print_report(wav_filenames, labels, decodings, losses, dataset_name) and returns: samples