code: def count_and_consider_only(speakers, lines, min_count=10):
      """
      consider speakers only if samples per speaker is at least min_count
      """
      uniq_speakers, indices, counts = np.unique(
          speakers, return_index=True, return_counts=True
      )
      print(
          "speaker count before filtering minimum number of speaker counts: ",
          len(uniq_speakers),
      )
      required_speakers = {}
      for idx, count in enumerate(counts):
          if count >= min_count:
              required_speakers[uniq_speakers[idx]] = count
  
      print(
          "speaker count after filtering minimum number of speaker counts: ",
          len(required_speakers),
      )
      required_lines = []
      speakers_only = []
      for idx, speaker in enumerate(speakers):
          if speaker in required_speakers:
              required_lines.append(lines[idx])
              speakers_only.append(speaker)
  
      return speakers_only, required_lines
  
file_path: NeMo/scripts/speaker_tasks/filelist_to_manifest.py
imports: import argparse
  import json
  import os
  import random
  import librosa
  import numpy
  import soundfile
  import sox
  from sklearn.model_selection import StratifiedShuffleSplit
  from tqdm.contrib.concurrent import process_map
  from nemo.collections.asr.parts.utils.manifest_utils import read_manifest
label_desc: Use image node_id 2 for calling a global function with example usage: count_and_consider_only(speakers, lines, min_count) and returns: speakers_only,  required_lines