docs: def open(dataset_dir, access_mode=READ_ONLY_ACCESS):
          """ Opens a tensor dataset. """
          # check access mode
          if access_mode == WRITE_ACCESS:
              raise ValueError('Cannot open a dataset with write-only access')
  
          # read config
          try:
              # json load
              config_filename = os.path.join(dataset_dir, 'config.json')
              config = json.load(open(config_filename, 'r'))
          except:
              # YAML load
              config_filename = os.path.join(dataset_dir, 'config.yaml')
              config = YamlConfig(config_filename)
  
          # open dataset
          dataset = TensorDataset(dataset_dir, config, access_mode=access_mode)
          return dataset