prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  KeyError: 'tfds_data_dir'(GANSynth)
  Hi, I got this error on GANSynth demo colab . How can I resolve it?
  
  ![image](https://user-images.githubusercontent.com/43649503/91554417-0a7d2400-e96a-11ea-9905-893c535b196a.png)
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `magenta/models/gansynth/gansynth_generate.py`
  Content:
  ```
  1 # Copyright 2020 The Magenta Authors.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 # Lint as: python3
  16 r"""Generate samples with a pretrained GANSynth model.
  17 
  18 To use a config of hyperparameters and manual hparams:
  19 >>> python magenta/models/gansynth/generate.py \
  20 >>> --ckpt_dir=/path/to/ckpt/dir --output_dir=/path/to/output/dir \
  21 >>> --midi_file=/path/to/file.mid
  22 
  23 If a MIDI file is specified, notes are synthesized with interpolation between
  24 latent vectors in time. If no MIDI file is given, a random batch of notes is
  25 synthesized.
  26 """
  27 
  28 import os
  29 
  30 import absl.flags
  31 from magenta.models.gansynth.lib import flags as lib_flags
  32 from magenta.models.gansynth.lib import generate_util as gu
  33 from magenta.models.gansynth.lib import model as lib_model
  34 from magenta.models.gansynth.lib import util
  35 import tensorflow.compat.v1 as tf
  36 
  37 
  38 absl.flags.DEFINE_string('ckpt_dir',
  39                          '/tmp/gansynth/acoustic_only',
  40                          'Path to the base directory of pretrained checkpoints.'
  41                          'The base directory should contain many '
  42                          '"stage_000*" subdirectories.')
  43 absl.flags.DEFINE_string('output_dir',
  44                          '/tmp/gansynth/samples',
  45                          'Path to directory to save wave files.')
  46 absl.flags.DEFINE_string('midi_file',
  47                          '',
  48                          'Path to a MIDI file (.mid) to synthesize.')
  49 absl.flags.DEFINE_integer('batch_size', 8, 'Batch size for generation.')
  50 absl.flags.DEFINE_float('secs_per_instrument', 6.0,
  51                         'In random interpolations, the seconds it takes to '
  52                         'interpolate from one instrument to another.')
  53 
  54 FLAGS = absl.flags.FLAGS
  55 tf.logging.set_verbosity(tf.logging.INFO)
  56 
  57 
  58 def main(unused_argv):
  59   absl.flags.FLAGS.alsologtostderr = True
  60 
  61   # Load the model
  62   flags = lib_flags.Flags({'batch_size_schedule': [FLAGS.batch_size]})
  63   model = lib_model.Model.load_from_path(FLAGS.ckpt_dir, flags)
  64 
  65   # Make an output directory if it doesn't exist
  66   output_dir = util.expand_path(FLAGS.output_dir)
  67   if not tf.gfile.Exists(output_dir):
  68     tf.gfile.MakeDirs(output_dir)
  69 
  70   if FLAGS.midi_file:
  71     # If a MIDI file is provided, synthesize interpolations across the clip
  72     unused_ns, notes = gu.load_midi(FLAGS.midi_file)
  73 
  74     # Distribute latent vectors linearly in time
  75     z_instruments, t_instruments = gu.get_random_instruments(
  76         model,
  77         notes['end_times'][-1],
  78         secs_per_instrument=FLAGS.secs_per_instrument)
  79 
  80     # Get latent vectors for each note
  81     z_notes = gu.get_z_notes(notes['start_times'], z_instruments, t_instruments)
  82 
  83     # Generate audio for each note
  84     print('Generating {} samples...'.format(len(z_notes)))
  85     audio_notes = model.generate_samples_from_z(z_notes, notes['pitches'])
  86 
  87     # Make a single audio clip
  88     audio_clip = gu.combine_notes(audio_notes,
  89                                   notes['start_times'],
  90                                   notes['end_times'],
  91                                   notes['velocities'])
  92 
  93     # Write the wave files
  94     fname = os.path.join(output_dir, 'generated_clip.wav')
  95     gu.save_wav(audio_clip, fname)
  96   else:
  97     # Otherwise, just generate a batch of random sounds
  98     waves = model.generate_samples(FLAGS.batch_size)
  99     # Write the wave files
  100     for i in range(len(waves)):
  101       fname = os.path.join(output_dir, 'generated_{}.wav'.format(i))
  102       gu.save_wav(waves[i], fname)
  103 
  104 
  105 def console_entry_point():
  106   tf.disable_v2_behavior()
  107   tf.app.run(main)
  108 
  109 
  110 if __name__ == '__main__':
  111   console_entry_point()
  112
  ```
  
  Path: `magenta/version.py`
  Content:
  ```
  1 # Copyright 2020 The Magenta Authors.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 r"""Separate file for storing the current version of Magenta.
  16 
  17 Stored in a separate file so that setup.py can reference the version without
  18 pulling in all the dependencies in __init__.py.
  19 """
  20 
  21 __version__ = '2.1.2'
  22
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/magenta/models/gansynth/gansynth_generate.py b/magenta/models/gansynth/gansynth_generate.py
  --- a/magenta/models/gansynth/gansynth_generate.py
  +++ b/magenta/models/gansynth/gansynth_generate.py
  @@ -50,6 +50,9 @@
   absl.flags.DEFINE_float('secs_per_instrument', 6.0,
                           'In random interpolations, the seconds it takes to '
                           'interpolate from one instrument to another.')
  +absl.flags.DEFINE_string('tfds_data_dir',
  +                         'gs://tfds-data/datasets',
  +                         'Data directory for the TFDS dataset used to train.')
   
   FLAGS = absl.flags.FLAGS
   tf.logging.set_verbosity(tf.logging.INFO)
  @@ -59,7 +62,11 @@
     absl.flags.FLAGS.alsologtostderr = True
   
     # Load the model
  -  flags = lib_flags.Flags({'batch_size_schedule': [FLAGS.batch_size]})
  +  flags = lib_flags.Flags(
  +      {
  +          'batch_size_schedule': [FLAGS.batch_size],
  +          'tfds_data_dir': FLAGS.tfds_data_dir
  +      })
     model = lib_model.Model.load_from_path(FLAGS.ckpt_dir, flags)
   
     # Make an output directory if it doesn't exist
  diff --git a/magenta/version.py b/magenta/version.py
  --- a/magenta/version.py
  +++ b/magenta/version.py
  @@ -18,4 +18,4 @@
   pulling in all the dependencies in __init__.py.
   """
   
  -__version__ = '2.1.2'
  +__version__ = '2.1.3'
  
verification_info: {"golden_diff": "diff --git a/magenta/models/gansynth/gansynth_generate.py b/magenta/models/gansynth/gansynth_generate.py\n--- a/magenta/models/gansynth/gansynth_generate.py\n+++ b/magenta/models/gansynth/gansynth_generate.py\n@@ -50,6 +50,9 @@\n absl.flags.DEFINE_float('secs_per_instrument', 6.0,\n                         'In random interpolations, the seconds it takes to '\n                         'interpolate from one instrument to another.')\n+absl.flags.DEFINE_string('tfds_data_dir',\n+                         'gs://tfds-data/datasets',\n+                         'Data directory for the TFDS dataset used to train.')\n \n FLAGS = absl.flags.FLAGS\n tf.logging.set_verbosity(tf.logging.INFO)\n@@ -59,7 +62,11 @@\n   absl.flags.FLAGS.alsologtostderr = True\n \n   # Load the model\n-  flags = lib_flags.Flags({'batch_size_schedule': [FLAGS.batch_size]})\n+  flags = lib_flags.Flags(\n+      {\n+          'batch_size_schedule': [FLAGS.batch_size],\n+          'tfds_data_dir': FLAGS.tfds_data_dir\n+      })\n   model = lib_model.Model.load_from_path(FLAGS.ckpt_dir, flags)\n \n   # Make an output directory if it doesn't exist\ndiff --git a/magenta/version.py b/magenta/version.py\n--- a/magenta/version.py\n+++ b/magenta/version.py\n@@ -18,4 +18,4 @@\n pulling in all the dependencies in __init__.py.\n \"\"\"\n \n-__version__ = '2.1.2'\n+__version__ = '2.1.3'\n", "issue": "KeyError: 'tfds_data_dir'(GANSynth)\nHi, I got this error on GANSynth demo colab . How can I resolve it?\r\n\r\n![image](https://user-images.githubusercontent.com/43649503/91554417-0a7d2400-e96a-11ea-9905-893c535b196a.png)\r\n\n", "before_files": [{"content": "# Copyright 2020 The Magenta Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# Lint as: python3\nr\"\"\"Generate samples with a pretrained GANSynth model.\n\nTo use a config of hyperparameters and manual hparams:\n>>> python magenta/models/gansynth/generate.py \\\n>>> --ckpt_dir=/path/to/ckpt/dir --output_dir=/path/to/output/dir \\\n>>> --midi_file=/path/to/file.mid\n\nIf a MIDI file is specified, notes are synthesized with interpolation between\nlatent vectors in time. If no MIDI file is given, a random batch of notes is\nsynthesized.\n\"\"\"\n\nimport os\n\nimport absl.flags\nfrom magenta.models.gansynth.lib import flags as lib_flags\nfrom magenta.models.gansynth.lib import generate_util as gu\nfrom magenta.models.gansynth.lib import model as lib_model\nfrom magenta.models.gansynth.lib import util\nimport tensorflow.compat.v1 as tf\n\n\nabsl.flags.DEFINE_string('ckpt_dir',\n                         '/tmp/gansynth/acoustic_only',\n                         'Path to the base directory of pretrained checkpoints.'\n                         'The base directory should contain many '\n                         '\"stage_000*\" subdirectories.')\nabsl.flags.DEFINE_string('output_dir',\n                         '/tmp/gansynth/samples',\n                         'Path to directory to save wave files.')\nabsl.flags.DEFINE_string('midi_file',\n                         '',\n                         'Path to a MIDI file (.mid) to synthesize.')\nabsl.flags.DEFINE_integer('batch_size', 8, 'Batch size for generation.')\nabsl.flags.DEFINE_float('secs_per_instrument', 6.0,\n                        'In random interpolations, the seconds it takes to '\n                        'interpolate from one instrument to another.')\n\nFLAGS = absl.flags.FLAGS\ntf.logging.set_verbosity(tf.logging.INFO)\n\n\ndef main(unused_argv):\n  absl.flags.FLAGS.alsologtostderr = True\n\n  # Load the model\n  flags = lib_flags.Flags({'batch_size_schedule': [FLAGS.batch_size]})\n  model = lib_model.Model.load_from_path(FLAGS.ckpt_dir, flags)\n\n  # Make an output directory if it doesn't exist\n  output_dir = util.expand_path(FLAGS.output_dir)\n  if not tf.gfile.Exists(output_dir):\n    tf.gfile.MakeDirs(output_dir)\n\n  if FLAGS.midi_file:\n    # If a MIDI file is provided, synthesize interpolations across the clip\n    unused_ns, notes = gu.load_midi(FLAGS.midi_file)\n\n    # Distribute latent vectors linearly in time\n    z_instruments, t_instruments = gu.get_random_instruments(\n        model,\n        notes['end_times'][-1],\n        secs_per_instrument=FLAGS.secs_per_instrument)\n\n    # Get latent vectors for each note\n    z_notes = gu.get_z_notes(notes['start_times'], z_instruments, t_instruments)\n\n    # Generate audio for each note\n    print('Generating {} samples...'.format(len(z_notes)))\n    audio_notes = model.generate_samples_from_z(z_notes, notes['pitches'])\n\n    # Make a single audio clip\n    audio_clip = gu.combine_notes(audio_notes,\n                                  notes['start_times'],\n                                  notes['end_times'],\n                                  notes['velocities'])\n\n    # Write the wave files\n    fname = os.path.join(output_dir, 'generated_clip.wav')\n    gu.save_wav(audio_clip, fname)\n  else:\n    # Otherwise, just generate a batch of random sounds\n    waves = model.generate_samples(FLAGS.batch_size)\n    # Write the wave files\n    for i in range(len(waves)):\n      fname = os.path.join(output_dir, 'generated_{}.wav'.format(i))\n      gu.save_wav(waves[i], fname)\n\n\ndef console_entry_point():\n  tf.disable_v2_behavior()\n  tf.app.run(main)\n\n\nif __name__ == '__main__':\n  console_entry_point()\n", "path": "magenta/models/gansynth/gansynth_generate.py"}, {"content": "# Copyright 2020 The Magenta Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nr\"\"\"Separate file for storing the current version of Magenta.\n\nStored in a separate file so that setup.py can reference the version without\npulling in all the dependencies in __init__.py.\n\"\"\"\n\n__version__ = '2.1.2'\n", "path": "magenta/version.py"}], "after_files": [{"content": "# Copyright 2020 The Magenta Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# Lint as: python3\nr\"\"\"Generate samples with a pretrained GANSynth model.\n\nTo use a config of hyperparameters and manual hparams:\n>>> python magenta/models/gansynth/generate.py \\\n>>> --ckpt_dir=/path/to/ckpt/dir --output_dir=/path/to/output/dir \\\n>>> --midi_file=/path/to/file.mid\n\nIf a MIDI file is specified, notes are synthesized with interpolation between\nlatent vectors in time. If no MIDI file is given, a random batch of notes is\nsynthesized.\n\"\"\"\n\nimport os\n\nimport absl.flags\nfrom magenta.models.gansynth.lib import flags as lib_flags\nfrom magenta.models.gansynth.lib import generate_util as gu\nfrom magenta.models.gansynth.lib import model as lib_model\nfrom magenta.models.gansynth.lib import util\nimport tensorflow.compat.v1 as tf\n\n\nabsl.flags.DEFINE_string('ckpt_dir',\n                         '/tmp/gansynth/acoustic_only',\n                         'Path to the base directory of pretrained checkpoints.'\n                         'The base directory should contain many '\n                         '\"stage_000*\" subdirectories.')\nabsl.flags.DEFINE_string('output_dir',\n                         '/tmp/gansynth/samples',\n                         'Path to directory to save wave files.')\nabsl.flags.DEFINE_string('midi_file',\n                         '',\n                         'Path to a MIDI file (.mid) to synthesize.')\nabsl.flags.DEFINE_integer('batch_size', 8, 'Batch size for generation.')\nabsl.flags.DEFINE_float('secs_per_instrument', 6.0,\n                        'In random interpolations, the seconds it takes to '\n                        'interpolate from one instrument to another.')\nabsl.flags.DEFINE_string('tfds_data_dir',\n                         'gs://tfds-data/datasets',\n                         'Data directory for the TFDS dataset used to train.')\n\nFLAGS = absl.flags.FLAGS\ntf.logging.set_verbosity(tf.logging.INFO)\n\n\ndef main(unused_argv):\n  absl.flags.FLAGS.alsologtostderr = True\n\n  # Load the model\n  flags = lib_flags.Flags(\n      {\n          'batch_size_schedule': [FLAGS.batch_size],\n          'tfds_data_dir': FLAGS.tfds_data_dir\n      })\n  model = lib_model.Model.load_from_path(FLAGS.ckpt_dir, flags)\n\n  # Make an output directory if it doesn't exist\n  output_dir = util.expand_path(FLAGS.output_dir)\n  if not tf.gfile.Exists(output_dir):\n    tf.gfile.MakeDirs(output_dir)\n\n  if FLAGS.midi_file:\n    # If a MIDI file is provided, synthesize interpolations across the clip\n    unused_ns, notes = gu.load_midi(FLAGS.midi_file)\n\n    # Distribute latent vectors linearly in time\n    z_instruments, t_instruments = gu.get_random_instruments(\n        model,\n        notes['end_times'][-1],\n        secs_per_instrument=FLAGS.secs_per_instrument)\n\n    # Get latent vectors for each note\n    z_notes = gu.get_z_notes(notes['start_times'], z_instruments, t_instruments)\n\n    # Generate audio for each note\n    print('Generating {} samples...'.format(len(z_notes)))\n    audio_notes = model.generate_samples_from_z(z_notes, notes['pitches'])\n\n    # Make a single audio clip\n    audio_clip = gu.combine_notes(audio_notes,\n                                  notes['start_times'],\n                                  notes['end_times'],\n                                  notes['velocities'])\n\n    # Write the wave files\n    fname = os.path.join(output_dir, 'generated_clip.wav')\n    gu.save_wav(audio_clip, fname)\n  else:\n    # Otherwise, just generate a batch of random sounds\n    waves = model.generate_samples(FLAGS.batch_size)\n    # Write the wave files\n    for i in range(len(waves)):\n      fname = os.path.join(output_dir, 'generated_{}.wav'.format(i))\n      gu.save_wav(waves[i], fname)\n\n\ndef console_entry_point():\n  tf.disable_v2_behavior()\n  tf.app.run(main)\n\n\nif __name__ == '__main__':\n  console_entry_point()\n", "path": "magenta/models/gansynth/gansynth_generate.py"}, {"content": "# Copyright 2020 The Magenta Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nr\"\"\"Separate file for storing the current version of Magenta.\n\nStored in a separate file so that setup.py can reference the version without\npulling in all the dependencies in __init__.py.\n\"\"\"\n\n__version__ = '2.1.3'\n", "path": "magenta/version.py"}]}