docstr: Tests accuracy of variable length delay.
  
  Generate a sine wave and delay at various amounts. If max_length is equal
  to the period of oscillation, a half wave delay is equal to negation and
  full wave delay is equal to identity.
  
  Args:
    batch_size: Number of batch examples in the test phase signal.
    n_samples: Number of samples in the test signal.
    max_length: Maximimum delay in samples.
docstr_tok: ["Tests","accuracy","of","variable","length","delay",".","Generate","a","sine","wave","and","delay","at","various","amounts",".","If","max_length","is","equal","to","the","period","of","oscillation",",","a","half","wave","delay","is","equal","to","negation","and","full","wave","delay","is","equal","to","identity",".","Args",":","batch_size",":","Number","of","batch","examples","in","the","test","phase","signal",".","n_samples",":","Number","of","samples","in","the","test","signal",".","max_length",":","Maximimum","delay","in","samples","."]
code: def test_variable_length_delay_is_accurate(
      self, batch_size, n_samples, max_length
  ):
      """Tests accuracy of variable length delay.
  
      Generate a sine wave and delay at various amounts. If max_length is equal
      to the period of oscillation, a half wave delay is equal to negation and
      full wave delay is equal to identity.
  
      Args:
        batch_size: Number of batch examples in the test phase signal.
        n_samples: Number of samples in the test signal.
        max_length: Maximimum delay in samples.
      """
      threshold = 1e-2
      # Start with a sin wave of same period as max_length.
      n_cycles = float(n_samples) / max_length
      wav_np = np.sin(np.linspace(0, 2.0 * np.pi * n_cycles, n_samples))
      wav_np = np.tile(wav_np[np.newaxis, :], [batch_size, 1]).astype(
          np.float32
      )
  
      # Three different decay amounts (none, half-wave, full-wave).
      ones = tf.ones_like(wav_np)[..., tf.newaxis]
      phase_no_delay = 0.0 * ones
      phase_half_delay = 0.5 * ones
      phase_full_delay = 1.0 * ones
  
      wav_tf_no_delay = core.variable_length_delay(
          phase_no_delay, wav_np, max_length
      )
      wav_tf_half_delay = core.variable_length_delay(
          phase_half_delay, wav_np, max_length
      )
      wav_tf_full_delay = core.variable_length_delay(
          phase_full_delay, wav_np, max_length
      )
  
      for target, source in [
          (wav_np, wav_tf_no_delay),
          (-wav_np, wav_tf_half_delay),
          (wav_np, wav_tf_full_delay),
      ]:
          # Ignore front of sample because of zero padding.
          difference = target[:, max_length:] - source[:, max_length:]
          difference = np.abs(difference).mean()
          self.assertLessEqual(difference, threshold)
  
imports: from absl.testing import parameterized
  from ddsp import core
  import librosa
  import numpy
  from scipy import signal
  import tensorflow.compat.v2
label_desc: Use image node_id 3 for calling the InterpolatingLookupTest obj's underlying member method code with example usage: obj.test_variable_length_delay_is_accurate(batch_size, n_samples, max_length) without return types