class_docstr: Class for retrieving different datasets.
class_docstr_tok: ["Class","for","retrieving","different","datasets","."]
docstr: Initialize a `Dataset` instance.
  
  Args:
    basepath: path to directory containing dataset npz files.
    hparams: Hyperparameters object.
    fold: data subset, one of {train,valid,test}.
  
  Raises:
    ValueError: if requested a temporal resolution shorter then that available
        in the dataset.
docstr_tok: ["Initialize","a","`","Dataset","`","instance",".","Args",":","basepath",":","path","to","directory","containing","dataset","npz","files",".","hparams",":","Hyperparameters","object",".","fold",":","data","subset",",","one","of","{","train",",","valid",",","test","}",".","Raises",":","ValueError",":","if","requested","a","temporal","resolution","shorter","then","that","available","in","the","dataset","."]
code: def __init__(self, basepath, hparams, fold):
      """Initialize a `Dataset` instance.
  
      Args:
        basepath: path to directory containing dataset npz files.
        hparams: Hyperparameters object.
        fold: data subset, one of {train,valid,test}.
  
      Raises:
        ValueError: if requested a temporal resolution shorter then that available
            in the dataset.
      """
      self.basepath = basepath
      self.hparams = hparams
      self.fold = fold
  
      if self.shortest_duration != self.hparams.quantization_level:
          raise ValueError(
              "The data has a temporal resolution of shortest "
              "duration=%r, requested=%r"
              % (
                  self.shortest_duration,
                  self.hparams.quantization_level,
              )
          )
  
      # Update the default pitch ranges in hparams to reflect that of dataset.
      hparams.pitch_ranges = [
          self.min_pitch,
          self.max_pitch,
      ]  # legacy hparam
      hparams.min_pitch = self.min_pitch
      hparams.max_pitch = self.max_pitch
      hparams.shortest_duration = self.shortest_duration
      hparams.dataset = self.key
      self.encoder = lib_pianoroll.get_pianoroll_encoder_decoder(
          hparams
      )
      data_path = os.path.join(
          tf.resource_loader.get_data_files_path(),
          self.basepath,
          "%s.npz" % self.name,
      )
      print("Loading data from", data_path)
      with tf.gfile.Open(data_path, "rb") as p:
          self.data = np.load(p, allow_pickle=True, encoding="latin1")[
              fold
          ]
  
imports: import os
  from magenta.models.coconet import lib_mask
  from magenta.models.coconet import lib_pianoroll
  from magenta.models.coconet import lib_util
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 1 to create a new Dataset object from inherited base classes: lib_util with example: obj = Dataset(basepath, hparams, fold)