code: def _calculate(line: dict, edge_len: int):
      """
      Calculates metrics for every entry on manifest.json.
  
      Args:
          line - line of manifest.json (dict)
          edge_len - number of characters for edge Character Error Rate (CER) calculations
  
      Returns:
          line - line of manifest.json (dict) with the following metrics added:
          WER - word error rate
          CER - character error rate
          start_CER - CER at the beginning of the audio sample considering first 'edge_len' characters
          end_CER - CER at the end of the audio sample considering last 'edge_len' characters
          len_diff_ratio - ratio between reference text length and predicted text length with respect to
              the reference text length (length measured in number of characters)
      """
      eps = 1e-9
  
      text = line["text"].split()
      pred_text = line["pred_text"].split()
  
      num_words = max(len(text), eps)
      word_dist = editdistance.eval(text, pred_text)
      line["WER"] = word_dist / num_words * 100.0
      num_chars = max(len(line["text"]), eps)
      char_dist = editdistance.eval(line["text"], line["pred_text"])
      line["CER"] = char_dist / num_chars * 100.0
  
      line["start_CER"] = (
          editdistance.eval(
              line["text"][:edge_len], line["pred_text"][:edge_len]
          )
          / edge_len
          * 100
      )
      line["end_CER"] = (
          editdistance.eval(
              line["text"][-edge_len:], line["pred_text"][-edge_len:]
          )
          / edge_len
          * 100
      )
      line["len_diff_ratio"] = (
          1.0 * abs(len(text) - len(pred_text)) / max(len(text), eps)
      )
      return line
  
file_path: NeMo/tools/ctc_segmentation/scripts/get_metrics_and_filter.py
imports: import argparse
  import json
  import os
  from glob import glob
  import editdistance
  from joblib import Parallel, delayed
  from tqdm import tqdm
  from nemo.collections.asr.parts.preprocessing.segment import AudioSegment
  from nemo.utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: _calculate(line, edge_len) and returns: line