code: def compute_th(PSD, barks, ATH, freqs):
      """returns the global masking threshold"""
      # Identification of tonal maskers
      # find the index of maskers that are the local maxima
      length = len(PSD)
      masker_index = signal.argrelextrema(PSD, np.greater)[0]
  
      # delete the boundary of maskers for smoothing
      if 0 in masker_index:
          masker_index = np.delete(0)
      if length - 1 in masker_index:
          masker_index = np.delete(length - 1)
      num_local_max = len(masker_index)
  
      # treat all the maskers as tonal (conservative way)
      # smooth the PSD
      p_k = pow(10, PSD[masker_index] / 10.0)
      p_k_prev = pow(10, PSD[masker_index - 1] / 10.0)
      p_k_post = pow(10, PSD[masker_index + 1] / 10.0)
      P_TM = 10 * np.log10(p_k_prev + p_k + p_k_post)
  
      # bark_psd: the first column bark, the second column: P_TM, the third column: the index of points
      _BARK = 0
      _PSD = 1
      _INDEX = 2
      bark_psd = np.zeros([num_local_max, 3])
      bark_psd[:, _BARK] = barks[masker_index]
      bark_psd[:, _PSD] = P_TM
      bark_psd[:, _INDEX] = masker_index
  
      # delete the masker that doesn't have the highest PSD within 0.5 Bark around its frequency
      for i in range(num_local_max):
          next = i + 1
          if next >= bark_psd.shape[0]:
              break
  
          while bark_psd[next, _BARK] - bark_psd[i, _BARK] < 0.5:
              # masker must be higher than quiet threshold
              if (
                  quiet(freqs[int(bark_psd[i, _INDEX])])
                  > bark_psd[i, _PSD]
              ):
                  bark_psd = np.delete(bark_psd, (i), axis=0)
              if next == bark_psd.shape[0]:
                  break
  
              if bark_psd[i, _PSD] < bark_psd[next, _PSD]:
                  bark_psd = np.delete(bark_psd, (i), axis=0)
              else:
                  bark_psd = np.delete(bark_psd, (next), axis=0)
              if next == bark_psd.shape[0]:
                  break
  
      # compute the individual masking threshold
      delta_TM = 1 * (-6.025 - 0.275 * bark_psd[:, 0])
      Ts = two_slops(bark_psd, delta_TM, barks)
      Ts = np.array(Ts)
  
      # compute the global masking threshold
      theta_x = np.sum(pow(10, Ts / 10.0), axis=0) + pow(10, ATH / 10.0)
  
      return theta_x
  
file_path: cleverhans/cleverhans_v3.1.0/examples/adversarial_asr/generate_masking_threshold.py
imports: import scipy.io.wavfile
  import numpy
  from scipy.fftpack import fft
  from scipy.fftpack import ifft
  from scipy import signal
  import scipy
  import librosa
label_desc: Use image node_id 5 for calling a global function with example usage: compute_th(PSD, barks, ATH, freqs) and returns: theta_x