code: def dev_ahc_threshold_tuner(full_meta, split_type):
      """Tuning threshold for affinity matrix. This function is called when AHC is used as backend."""
  
      DER_list = []
      prange = np.arange(0.0, 1.0, 0.1)
  
      n_lambdas = None  # using it as flag later.
  
      # Note: p_val is threshold in case of AHC.
      for p_v in prange:
          # Process whole dataset for value of p_v.
          concate_rttm_file = diarize_dataset(
              full_meta, split_type, n_lambdas, p_v
          )
  
          ref_rttm = os.path.join(
              params["ref_rttm_dir"], "fullref_ami_dev.rttm"
          )
          sys_rttm = concate_rttm_file
          [MS, FA, SER, DER_] = DER(
              ref_rttm,
              sys_rttm,
              params["ignore_overlap"],
              params["forgiveness_collar"],
          )
  
          DER_list.append(DER_)
  
          if params["oracle_n_spkrs"] is True:
              break  # no need of threshold search.
  
      # Take p_val that gave minmum DER on Dev dataset.
      tuned_p_val = prange[DER_list.index(min(DER_list))]
  
      return tuned_p_val
  
imports: import os
  import sys
  import torch
  import logging
  import pickle
  import json
  import glob
  import shutil
  import numpy
  import speechbrain
  from tqdm.contrib import tqdm
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main
  from speechbrain.processing.PLDA_LDA import StatObject_SB
  from speechbrain.processing import diarization
  from speechbrain.utils.DER import DER
  from speechbrain.dataio.dataio import read_audio
  from speechbrain.dataio.dataio import read_audio_multichannel
label_desc: Use image node_id 6 for calling a global function with example usage: dev_ahc_threshold_tuner(full_meta, split_type) and returns: tuned_p_val