code: def _apply_filters(
      manifest,
      manifest_out,
      max_cer,
      max_wer,
      max_edge_cer,
      max_len_diff_ratio,
      max_dur=-1,
      min_dur=1,
      original_duration=0,
  ):
      """Filters out samples that do not satisfy specified threshold values and saves remaining samples to manifest_out"""
      remaining_duration = 0
      segmented_duration = 0
      with open(manifest, "r") as f, open(manifest_out, "w") as f_out:
          for line in f:
              item = json.loads(line)
              cer = item["CER"]
              wer = item["WER"]
              len_diff_ratio = item["len_diff_ratio"]
              duration = item["duration"]
              segmented_duration += duration
              if (
                  cer <= max_cer
                  and wer <= max_wer
                  and len_diff_ratio <= max_len_diff_ratio
                  and item["end_CER"] <= max_edge_cer
                  and item["start_CER"] <= max_edge_cer
                  and (
                      max_dur == -1
                      or (max_dur > -1 and duration < max_dur)
                  )
                  and duration > min_dur
              ):
                  remaining_duration += duration
                  f_out.write(json.dumps(item) + "\n")
  
      logging.info("-" * 50)
      logging.info("Threshold values:")
      logging.info(f"max WER, %: {max_wer}")
      logging.info(f"max CER, %: {max_cer}")
      logging.info(f"max edge CER, %: {max_edge_cer}")
      logging.info(f"max Word len diff: {max_len_diff_ratio}")
      logging.info(f"max Duration, s: {max_dur}")
      logging.info("-" * 50)
  
      remaining_duration = remaining_duration / 60
      original_duration = original_duration / 60
      segmented_duration = segmented_duration / 60
      logging.info(
          f"Original audio dur: {round(original_duration, 2)} min"
      )
      logging.info(
          f"Segmented duration: {round(segmented_duration, 2)} min ({round(100 * segmented_duration / original_duration, 2)}% of original audio)"
      )
      logging.info(
          f"Retained {round(remaining_duration, 2)} min ({round(100*remaining_duration/original_duration, 2)}% of original or {round(100 * remaining_duration / segmented_duration, 2)}% of segmented audio)."
      )
      logging.info(f"Retained data saved to {manifest_out}")
  
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 3 for calling a global function with example usage: _apply_filters(manifest, manifest_out, max_cer, max_wer, max_edge_cer, max_len_diff_ratio, max_dur, min_dur, original_duration) without return types