class_docstr: The Bach dataset 
docstr: Bach Choral Harmony dataset [1], [2]
  open-ml-id: 4552
  https://archive.ics.uci.edu/ml/datasets/Bach+Choral+Harmony
  
  Abstract: The data set is composed of 60 chorales (5665 events) by
  J.S. Bach (1675-1750). Each event of each chorale is labelled using 1
  among 101 chord labels and described through 14 features.
  
  Data Set Information:
  
  Pitch classes information has been extracted from MIDI sources downloaded
  from (JSB Chorales)[http://www.jsbchorales.net/]. Meter information has
  been computed through the Meter program which is part of the Melisma
  music analyser (Melisma)[http://www.link.cs.cmu.edu/music-analysis/].
  Chord labels have been manually annotated by a human expert.
  
  Attribute Information:
  
  1. Choral ID: corresponding to the file names from (Bach Central)[http://www.bachcentral.com/].
  2. Event number: index (starting from 1) of the event inside the chorale.
  3-14. Pitch classes: YES/NO depending on whether a given pitch is present.
  Pitch classes/attribute correspondence is as follows:
  C -> 3
  C#/Db -> 4
  D -> 5
  ...
  B -> 14
  15. Bass: Pitch class of the bass note
  16. Meter: integers from 1 to 5. Lower numbers denote less accented events,
  higher numbers denote more accented events.
  17. Chord label: Chord resonating during the given event.
  
  Notes
  ----------
  
  The features V1 and V2 are dropped during the processing. V1 is the Choral ID. V2 is
  the event number of the event inside the chorale.
  
  Parameters
  ----------
  root : string
      Root directory where the dataset folder `bach` exists.
  
  num_classes_per_task : int
      Number of classes per tasks. This corresponds to "N" in "N-way"
      classification.
  
  meta_train : bool (default: `False`)
      Use the meta-train split of the dataset. If set to `True`, then the
      arguments `meta_val` and `meta_test` must be set to `False`. Exactly one
      of these three arguments must be set to `True`.
  
  meta_val : bool (default: `False`)
      Use the meta-validation split of the dataset. If set to `True`, then the
      arguments `meta_train` and `meta_test` must be set to `False`. Exactly
      one of these three arguments must be set to `True`.
  
  meta_test : bool (default: `False`)
      Use the meta-test split of the dataset. If set to `True`, then the
      arguments `meta_train` and `meta_val` must be set to `False`. Exactly
      one of these three arguments must be set to `True`.
  
  meta_split : string in {'train', 'val', 'test'}, optional
      Name of the split to use. This overrides the arguments `meta_train`,
      `meta_val` and `meta_test` if all three are set to `False`.
  
  transform : callable, optional
      A function/transform that takes a numpy array or a pytorch array
      (depending when the transforms is applied), and returns a transformed
      version.
  
  target_transform : callable, optional
      A function/transform that takes a target, and returns a transformed
      version.
  
  dataset_transform : callable, optional
      A function/transform that takes a dataset (ie. a task), and returns a
      transformed version of it. E.g. `torchmeta.transforms.ClassSplitter()`.
  
  class_augmentations : list of callable, optional
      A list of functions that augment the dataset with new classes. These
      classes are transformations of existing classes.
  
  download : bool (default: `False`)
      If `True`, downloads the original files and processes the dataset in the
      root directory (under the `bach' folder). If the dataset
      is already available, this does not download/process the dataset again.
  
  process_features : bool (default: `True`)
      If `True`, normalizes the numeric feature f according to (f-lower) / (upper - lower) where upper
      and lower are the min and max values of feature f of the meta-train dataset.
      And also one-hot encodes the categorical features.
  
  min_num_samples_per_class : int (default: 1)
      Minimal number of samples per class that need to be present for the class to be used.
  
  References
  -----
  
  [1] D. P. Radicioni and R. Esposito. Advances in Music Information Retrieval,
  chapter BREVE: an HMPerceptron-Based Chord Recognition System.
  Studies in Computational Intelligence,
  Zbigniew W. Ras and Alicja Wieczorkowska (Editors), Springer, 2010.
  
  [2] Esposito, R. and Radicioni, D. P., CarpeDiem: Optimizing the Viterbi
  Algorithm and Applications to Supervised Sequential Learning, Journal
  of Machine Learning Research, 10(Aug):1851-1880, 2009.
docstr_tok: ["Bach","Choral","Harmony","dataset","[","1","]",",","[","2","]","open-ml-id",":","4552","https",":","\/\/archive.ics.uci.edu\/ml\/datasets\/Bach+Choral+Harmony","Abstract",":","The","data","set","is","composed","of","60","chorales","(","5665","events",")","by","J.S",".","Bach","(","1675-1750",")",".","Each","event","of","each","chorale","is","labelled","using","1","among","101","chord","labels","and","described","through","14","features",".","Data","Set","Information",":","Pitch","classes","information","has","been","extracted","from","MIDI","sources","downloaded","from","(","JSB","Chorales",")","[","http",":","\/\/www.jsbchorales.net\/","]",".","Meter","information","has","been","computed","through","the","Meter","program","which","is","part","of","the","Melisma","music","analyser","(","Melisma",")","[","http",":","\/\/www.link.cs.cmu.edu\/music-analysis\/","]",".","Chord","labels","have","been","manually","annotated","by","a","human","expert",".","Attribute","Information",":","1",".","Choral","ID",":","corresponding","to","the","file","names","from","(","Bach","Central",")","[","http",":","\/\/www.bachcentral.com\/","]",".","2",".","Event","number",":","index","(","starting","from","1",")","of","the","event","inside","the","chorale",".","3-14",".","Pitch","classes",":","YES\/NO","depending","on","whether","a","given","pitch","is","present",".","Pitch","classes\/attribute","correspondence","is","as","follows",":","C","-",">","3","C","#","\/Db","-",">","4","D","-",">","5","...","B","-",">","14","15",".","Bass",":","Pitch","class","of","the","bass","note","16",".","Meter",":","integers","from","1","to","5",".","Lower","numbers","denote","less","accented","events",",","higher","numbers","denote","more","accented","events",".","17",".","Chord","label",":","Chord","resonating","during","the","given","event",".","Notes","--","--","--","--","--","The","features","V1","and","V2","are","dropped","during","the","processing",".","V1","is","the","Choral","ID",".","V2","is","the","event","number","of","the","event","inside","the","chorale",".","Parameters","--","--","--","--","--","root",":","string","Root","directory","where","the","dataset","folder","`","bach","`","exists",".","num_classes_per_task",":","int","Number","of","classes","per","tasks",".","This","corresponds","to","``","N","''","in","``","N-way","''","classification",".","meta_train",":","bool","(","default",":","`","False","`",")","Use","the","meta-train","split","of","the","dataset",".","If","set","to","`","True","`",",","then","the","arguments","`","meta_val","`","and","`","meta_test","`","must","be","set","to","`","False","`",".","Exactly","one","of","these","three","arguments","must","be","set","to","`","True","`",".","meta_val",":","bool","(","default",":","`","False","`",")","Use","the","meta-validation","split","of","the","dataset",".","If","set","to","`","True","`",",","then","the","arguments","`","meta_train","`","and","`","meta_test","`","must","be","set","to","`","False","`",".","Exactly","one","of","these","three","arguments","must","be","set","to","`","True","`",".","meta_test",":","bool","(","default",":","`","False","`",")","Use","the","meta-test","split","of","the","dataset",".","If","set","to","`","True","`",",","then","the","arguments","`","meta_train","`","and","`","meta_val","`","must","be","set","to","`","False","`",".","Exactly","one","of","these","three","arguments","must","be","set","to","`","True","`",".","meta_split",":","string","in","{","'train","'",",","'val","'",",","'test","'","}",",","optional","Name","of","the","split","to","use",".","This","overrides","the","arguments","`","meta_train","`",",","`","meta_val","`","and","`","meta_test","`","if","all","three","are","set","to","`","False","`",".","transform",":","callable",",","optional","A","function\/transform","that","takes","a","numpy","array","or","a","pytorch","array","(","depending","when","the","transforms","is","applied",")",",","and","returns","a","transformed","version",".","target_transform",":","callable",",","optional","A","function\/transform","that","takes","a","target",",","and","returns","a","transformed","version",".","dataset_transform",":","callable",",","optional","A","function\/transform","that","takes","a","dataset","(","ie",".","a","task",")",",","and","returns","a","transformed","version","of","it",".","E.g",".","`","torchmeta.transforms.ClassSplitter","(",")","`",".","class_augmentations",":","list","of","callable",",","optional","A","list","of","functions","that","augment","the","dataset","with","new","classes",".","These","classes","are","transformations","of","existing","classes",".","download",":","bool","(","default",":","`","False","`",")","If","`","True","`",",","downloads","the","original","files","and","processes","the","dataset","in","the","root","directory","(","under","the","`","bach","'","folder",")",".","If","the","dataset","is","already","available",",","this","does","not","download\/process","the","dataset","again",".","process_features",":","bool","(","default",":","`","True","`",")","If","`","True","`",",","normalizes","the","numeric","feature","f","according","to","(","f-lower",")","\/","(","upper","-","lower",")","where","upper","and","lower","are","the","min","and","max","values","of","feature","f","of","the","meta-train","dataset",".","And","also","one-hot","encodes","the","categorical","features",".","min_num_samples_per_class",":","int","(","default",":","1",")","Minimal","number","of","samples","per","class","that","need","to","be","present","for","the","class","to","be","used",".","References","--","--","-","[","1","]","D.","P.","Radicioni","and","R.","Esposito",".","Advances","in","Music","Information","Retrieval",",","chapter","BREVE",":","an","HMPerceptron-Based","Chord","Recognition","System",".","Studies","in","Computational","Intelligence",",","Zbigniew","W.","Ras","and","Alicja","Wieczorkowska","(","Editors",")",",","Springer",",","2010",".","[","2","]","Esposito",",","R.","and","Radicioni",",","D.","P.",",","CarpeDiem",":","Optimizing","the","Viterbi","Algorithm","and","Applications","to","Supervised","Sequential","Learning",",","Journal","of","Machine","Learning","Research",",","10","(","Aug",")",":1851-1880",",","2009","."]
code: def __init__(
      self,
      root,
      num_classes_per_task=None,
      meta_train=False,
      meta_val=False,
      meta_test=False,
      meta_split=None,
      transform=None,
      target_transform=None,
      dataset_transform=None,
      class_augmentations=None,
      download=False,
      process_features=True,
      min_num_samples_per_class=1,
  ):
      """
      Bach Choral Harmony dataset [1], [2]
      open-ml-id: 4552
      https://archive.ics.uci.edu/ml/datasets/Bach+Choral+Harmony
  
      Abstract: The data set is composed of 60 chorales (5665 events) by
      J.S. Bach (1675-1750). Each event of each chorale is labelled using 1
      among 101 chord labels and described through 14 features.
  
      Data Set Information:
  
      Pitch classes information has been extracted from MIDI sources downloaded
      from (JSB Chorales)[http://www.jsbchorales.net/]. Meter information has
      been computed through the Meter program which is part of the Melisma
      music analyser (Melisma)[http://www.link.cs.cmu.edu/music-analysis/].
      Chord labels have been manually annotated by a human expert.
  
      Attribute Information:
  
      1. Choral ID: corresponding to the file names from (Bach Central)[http://www.bachcentral.com/].
      2. Event number: index (starting from 1) of the event inside the chorale.
      3-14. Pitch classes: YES/NO depending on whether a given pitch is present.
      Pitch classes/attribute correspondence is as follows:
      C -> 3
      C#/Db -> 4
      D -> 5
      ...
      B -> 14
      15. Bass: Pitch class of the bass note
      16. Meter: integers from 1 to 5. Lower numbers denote less accented events,
      higher numbers denote more accented events.
      17. Chord label: Chord resonating during the given event.
  
      Notes
      ----------
  
      The features V1 and V2 are dropped during the processing. V1 is the Choral ID. V2 is
      the event number of the event inside the chorale.
  
      Parameters
      ----------
      root : string
          Root directory where the dataset folder `bach` exists.
  
      num_classes_per_task : int
          Number of classes per tasks. This corresponds to "N" in "N-way"
          classification.
  
      meta_train : bool (default: `False`)
          Use the meta-train split of the dataset. If set to `True`, then the
          arguments `meta_val` and `meta_test` must be set to `False`. Exactly one
          of these three arguments must be set to `True`.
  
      meta_val : bool (default: `False`)
          Use the meta-validation split of the dataset. If set to `True`, then the
          arguments `meta_train` and `meta_test` must be set to `False`. Exactly
          one of these three arguments must be set to `True`.
  
      meta_test : bool (default: `False`)
          Use the meta-test split of the dataset. If set to `True`, then the
          arguments `meta_train` and `meta_val` must be set to `False`. Exactly
          one of these three arguments must be set to `True`.
  
      meta_split : string in {'train', 'val', 'test'}, optional
          Name of the split to use. This overrides the arguments `meta_train`,
          `meta_val` and `meta_test` if all three are set to `False`.
  
      transform : callable, optional
          A function/transform that takes a numpy array or a pytorch array
          (depending when the transforms is applied), and returns a transformed
          version.
  
      target_transform : callable, optional
          A function/transform that takes a target, and returns a transformed
          version.
  
      dataset_transform : callable, optional
          A function/transform that takes a dataset (ie. a task), and returns a
          transformed version of it. E.g. `torchmeta.transforms.ClassSplitter()`.
  
      class_augmentations : list of callable, optional
          A list of functions that augment the dataset with new classes. These
          classes are transformations of existing classes.
  
      download : bool (default: `False`)
          If `True`, downloads the original files and processes the dataset in the
          root directory (under the `bach' folder). If the dataset
          is already available, this does not download/process the dataset again.
  
      process_features : bool (default: `True`)
          If `True`, normalizes the numeric feature f according to (f-lower) / (upper - lower) where upper
          and lower are the min and max values of feature f of the meta-train dataset.
          And also one-hot encodes the categorical features.
  
      min_num_samples_per_class : int (default: 1)
          Minimal number of samples per class that need to be present for the class to be used.
  
      References
      -----
  
      [1] D. P. Radicioni and R. Esposito. Advances in Music Information Retrieval,
      chapter BREVE: an HMPerceptron-Based Chord Recognition System.
      Studies in Computational Intelligence,
      Zbigniew W. Ras and Alicja Wieczorkowska (Editors), Springer, 2010.
  
      [2] Esposito, R. and Radicioni, D. P., CarpeDiem: Optimizing the Viterbi
      Algorithm and Applications to Supervised Sequential Learning, Journal
      of Machine Learning Research, 10(Aug):1851-1880, 2009.
      """
      dataset = BachClassDataset(
          root,
          meta_train=meta_train,
          meta_val=meta_val,
          meta_test=meta_test,
          meta_split=meta_split,
          transform=transform,
          class_augmentations=class_augmentations,
          download=download,
          process_features=process_features,
          min_num_samples_per_class=min_num_samples_per_class,
      )
      super(Bach, self).__init__(
          dataset,
          num_classes_per_task,
          target_transform=target_transform,
          dataset_transform=dataset_transform,
      )
  
imports: import numpy
  import os
  import json
  import h5py
  from tqdm import tqdm
  from torchmeta.utils.data import Dataset, ClassDataset, CombinationMetaDataset
  from torchmeta.datasets.utils import get_asset
label_desc: Use image node_id 1 to create a new Bach object from inherited base classes: CombinationMetaDataset with example: obj = Bach(root, num_classes_per_task, meta_train, meta_val, meta_test, meta_split, transform, target_transform, dataset_transform, class_augmentations, download, process_features, min_num_samples_per_class)