code: def generate_notes(
      n_batch,
      n_timesteps,
      n_harmonics=100,
      n_mags=65,
      get_controls=True,
  ):
      """Generate self-supervision signal of discrete notes."""
      n_notes = uniform_int(1, 20)
  
      # Amplitudes.
      method = "nearest" if flip(0.5) else "linear"
      harm_amp = uniform_generator(
          [n_batch, n_notes, 1],
          n_timesteps,
          minval=-2,
          maxval=2,
          method=method,
      )
      if get_controls:
          harm_amp = ddsp.core.exp_sigmoid(harm_amp)
  
      # Frequencies.
      note_midi = uniform_generator(
          [n_batch, n_notes, 1],
          n_timesteps,
          minval=24.0,
          maxval=84.0,
          method="nearest",
      )
      f0_hz = ddsp.core.midi_to_hz(note_midi)
  
      # Harmonic Distribution
      method = "nearest" if flip(0.5) else "linear"
      n_lines = 10
      exponents = [uniform_float(1.0, 6.0) for _ in range(n_lines)]
      harm_dist_lines = [
          -tf.linspace(0.0, float(i), n_harmonics) ** exponents[i]
          for i in range(n_lines)
      ]
      harm_dist_lines = tf.stack(harm_dist_lines)
      lines_dist = uniform_generator(
          [n_batch, n_notes, n_lines],
          n_timesteps,
          minval=0.0,
          maxval=1.0,
          method=method,
      )
      harm_dist = (
          lines_dist[..., tf.newaxis]
          * harm_dist_lines[tf.newaxis, tf.newaxis, :]
      )
      harm_dist = tf.reduce_sum(harm_dist, axis=-2)
  
      if get_controls:
          harm_dist = ddsp.core.exp_sigmoid(harm_dist)
          harm_dist = ddsp.core.remove_above_nyquist(f0_hz, harm_dist)
          harm_dist = ddsp.core.safe_divide(
              harm_dist,
              tf.reduce_sum(harm_dist, axis=-1, keepdims=True),
          )
  
      # Noise Magnitudes.
      method = "nearest" if flip(0.5) else "linear"
      mags = uniform_generator(
          [n_batch, n_notes, n_mags],
          n_timesteps,
          minval=-6.0,
          maxval=uniform_float(-4.0, 0.0),
          method=method,
      )
      if get_controls:
          mags = ddsp.core.exp_sigmoid(mags)
  
      sin_amps, sin_freqs = ddsp.core.harmonic_to_sinusoidal(
          harm_amp, harm_dist, f0_hz
      )
  
      controls = {
          "harm_amp": harm_amp,
          "harm_dist": harm_dist,
          "f0_hz": f0_hz,
          "sin_amps": sin_amps,
          "sin_freqs": sin_freqs,
          "noise_magnitudes": mags,
      }
      return controls
  
file_path: ddsp/ddsp/training/data_preparation/synthetic_data.py
imports: import warnings
  import ddsp
  import gin
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 7 for calling a global function with example usage: generate_notes(n_batch, n_timesteps, n_harmonics, n_mags, get_controls) and returns: controls