<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_data(path, dense=False):
 """Load data from a CSV, LibSVM or HDF5 file based on the file extension. Args: path (str):
 A path to the CSV, LibSVM or HDF5 format file containing data. dense (boolean):
 An optional variable indicating if the return matrix should be dense. By default, it is false. Returns: Data matrix X and target vector y """


    catalog = {'.csv': load_csv, '.sps': load_svmlight_file, '.h5': load_hdf5}

    ext = os.path.splitext(path)[1]
    func = catalog[ext]
    X, y = func(path)

    if dense and sparse.issparse(X):
        X = X.todense()

    return X, y