docstr: Tests if Model builds properly and produces audio of correct shape.
  
  Args:
    sample_rate: Sample rate of audio.
    frame_rate: Frame rate of features.
    centered: Add an additional frame.
    gin_file: Name of gin_file to use.
docstr_tok: ["Tests","if","Model","builds","properly","and","produces","audio","of","correct","shape",".","Args",":","sample_rate",":","Sample","rate","of","audio",".","frame_rate",":","Frame","rate","of","features",".","centered",":","Add","an","additional","frame",".","gin_file",":","Name","of","gin_file","to","use","."]
code: def test_build_model(
      self, sample_rate, frame_rate, centered, gin_file
  ):
      """Tests if Model builds properly and produces audio of correct shape.
  
      Args:
        sample_rate: Sample rate of audio.
        frame_rate: Frame rate of features.
        centered: Add an additional frame.
        gin_file: Name of gin_file to use.
      """
      n_batch = 1
      n_secs = 4
      # frame_size = sample_rate // frame_rate
      n_frames = int(frame_rate * n_secs)
      n_samples = int(sample_rate * n_secs)
      n_samples_16k = int(16000 * n_secs)
      if centered:
          n_frames += 1
          # n_samples += frame_size
          # n_samples_16k += 320
  
      inputs = {
          "loudness_db": np.zeros([n_batch, n_frames]),
          "f0_hz": np.zeros([n_batch, n_frames]),
          "f0_confidence": np.zeros([n_batch, n_frames]),
          "audio": np.random.randn(n_batch, n_samples),
          "audio_16k": np.random.randn(n_batch, n_samples_16k),
      }
      inputs = {k: tf_float32(v) for k, v in inputs.items()}
  
      with gin.unlock_config():
          gin.clear_config()
          gin.parse_config_file(gin_file)
  
      model = models.Autoencoder()
      outputs = model(inputs)
      self.assertIsInstance(outputs, dict)
      # Confirm that model generates correctly sized audio.
      audio_gen = model.get_audio_from_outputs(outputs)
      audio_gen_shape = audio_gen.shape.as_list()
      self.assertEqual(audio_gen_shape, list(inputs["audio"].shape))
  
file_path: ddsp/ddsp/training/models/autoencoder_test.py
imports: from absl.testing import parameterized
  from ddsp.core import tf_float32
  from ddsp.training import models
  import gin
  import numpy
  import pkg_resources
  import tensorflow
label_desc: Use image node_id 1 for calling the AutoencoderTest obj's underlying member method code with example usage: obj.test_build_model(sample_rate, frame_rate, centered, gin_file) without return types