code: def calculate_delay(
      original_signal,
      delayed_signal,
      min_lag_in_samples,
      max_lag_in_samples,
      debug=False,
  ):
      coefs = []
      for lag in range(min_lag_in_samples, max_lag_in_samples):
          correlation_coef = fast_autocorr(
              original_signal, delayed_signal, t=lag
          )
          coefs.append(correlation_coef)
  
      max_coef_index = int(np.argmax(coefs))
  
      if coefs[max_coef_index] < 0.3:
          print(
              "Warning: Max coefficient is low ({})! Please check if the delay is out of bounds".format(
                  coefs[max_coef_index]
              )
          )
      delay = max_coef_index + min_lag_in_samples
  
      if debug:
          plt.plot(coefs)
          plt.show()
  
      return delay
  
file_path: audiomentations/tests/test_mp3_compression.py
imports: import os
  import matplotlib.pyplot
  import numpy
  import pytest
  from audiomentations import Mp3Compression
  from audiomentations.core.audio_loading_utils import load_sound_file
  from demo.demo import DEMO_DIR
label_desc: Use image node_id 2 for calling a global function with example usage: calculate_delay(original_signal, delayed_signal, min_lag_in_samples, max_lag_in_samples, debug) and returns: delay