code: def get_adaptive_threshold(
      estimated_num_of_spks: int,
      min_threshold: float,
      overlap_infer_spk_limit: int,
  ):
      """
      This function controls the magnitude of the sigmoid threshold based on the estimated number of speakers. As the number of
      speakers becomes larger, diarization error rate is very sensitive on overlap speech detection. This function linearly increases
      the threshold in proportion to the estimated number of speakers so more confident overlap speech results are reflected when
      the number of estimated speakers are relatively high.
  
      Args:
          estimated_num_of_spks (int):
              Estimated number of speakers from the clustering result.
          min_threshold (float):
              Sigmoid threshold value from the config file. This threshold value is minimum threshold value when `estimated_num_of_spks=2`
          overlap_infer_spk_limit (int):
              If the `estimated_num_of_spks` is less then `overlap_infer_spk_limit`, overlap speech estimation is skipped.
  
      Returns:
          adaptive_threshold (float):
              Threshold value that is scaled based on the `estimated_num_of_spks`.
      """
      adaptive_threshold = min_threshold - (
          estimated_num_of_spks - 2
      ) * (min_threshold - 1) / (overlap_infer_spk_limit - 2)
      return adaptive_threshold
  
imports: import gc
  import json
  import math
  import os
  import shutil
  from copy import deepcopy
  from typing import Dict, List, Tuple, Union
  import numpy
  import omegaconf
  import soundfile
  import torch
  from pyannote.core import Annotation, Segment
  from tqdm import tqdm
  from nemo.collections.asr.data.audio_to_label import repeat_signal
  from nemo.collections.asr.parts.utils.longform_clustering import LongFormSpeakerClustering
  from nemo.collections.asr.parts.utils.offline_clustering import SpeakerClustering, get_argmin_mat, split_input_data
  from nemo.utils import logging
label_desc: Use image node_id 42 for calling a global function with example usage: get_adaptive_threshold(estimated_num_of_spks, min_threshold, overlap_infer_spk_limit) and returns: adaptive_threshold