'Args:
name (str): \'train\', \'test\', \'val\'
data_dir (str): a directory containing the original \'BSR\' directory.'

def __init__(self, name, data_dir=None, shuffle=True):

    if (data_dir is None):
        data_dir = get_dataset_path('bsds500_data')
    if (not os.path.isdir(os.path.join(data_dir, 'BSR'))):
        download(DATA_URL, data_dir)
        filename = DATA_URL.split('/')[(-1)]
        filepath = os.path.join(data_dir, filename)
        import tarfile
        tarfile.open(filepath, 'r:gz').extractall(data_dir)
    self.data_root = os.path.join(data_dir, 'BSR', 'BSDS500', 'data')
    assert os.path.isdir(self.data_root)
    self.shuffle = shuffle
    assert (name in ['train', 'test', 'val'])
    self._load(name)
