class_docstr: Urmp training set with midi note data.
  
  This class loads the segmented data in tfrecord that contains 4-second audio
  clips of the URMP dataset. To load tfrecord that contains unsegmented full
  piece of URMP recording, please use `UrmpMidiUnsegmented` class instead.
class_docstr_tok: ["Urmp","training","set","with","midi","note","data",".","This","class","loads","the","segmented","data","in","tfrecord","that","contains","4-second","audio","clips","of","the","URMP","dataset",".","To","load","tfrecord","that","contains","unsegmented","full","piece","of","URMP","recording",",","please","use","`","UrmpMidiUnsegmented","`","class","instead","."]
code: def get_dataset(self, shuffle=True):
      instrument_ids = range(len(self._INSTRUMENTS))
      inst_vocab = tf.lookup.StaticHashTable(
          tf.lookup.KeyValueTensorInitializer(
              self._INSTRUMENTS, instrument_ids
          ),
          -1,
      )
  
      def _reshape_tensors(data):
          data["note_active_frame_indices"] = tf.reshape(
              data["note_active_frame_indices"], (-1, 128)
          )
          data["note_active_velocities"] = tf.reshape(
              data["note_active_velocities"], (-1, 128)
          )
          data["instrument_id"] = inst_vocab.lookup(
              data["instrument_id"]
          )
          data["midi"] = tf.argmax(
              data["note_active_frame_indices"], axis=-1
          )
          data["f0_hz"] = data["f0_hz"][..., tf.newaxis]
          data["loudness_db"] = data["loudness_db"][..., tf.newaxis]
          onsets = tf.reduce_sum(
              tf.reshape(data["note_onsets"], (-1, 128)), axis=-1
          )
          data["onsets"] = tf.cast(onsets > 0, tf.int64)
          offsets = tf.reduce_sum(
              tf.reshape(data["note_offsets"], (-1, 128)), axis=-1
          )
          data["offsets"] = tf.cast(offsets > 0, tf.int64)
  
          return data
  
      ds = super().get_dataset(shuffle)
      ds = ds.map(_reshape_tensors, num_parallel_calls=_AUTOTUNE)
      return ds
  
imports: import os
  from absl import logging
  from ddsp.spectral_ops import CREPE_FRAME_SIZE
  from ddsp.spectral_ops import CREPE_SAMPLE_RATE
  from ddsp.spectral_ops import get_framed_lengths
  import gin
  import tensorflow.compat.v2
  import tensorflow_datasets
label_desc: Use image node_id 2 for calling the UrmpMidi obj's underlying member method code with example usage: obj.get_dataset(shuffle) and returns: ds, data