<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_svhn(which_format, directory, output_directory, output_filename=None):
 """Converts the SVHN dataset to HDF5. Converts the SVHN dataset [SVHN] to an HDF5 dataset compatible with :class:`fuel.datasets.SVHN`. The converted dataset is saved as 'svhn_format_1.hdf5' or 'svhn_format_2.hdf5', depending on the `which_format` argument. .. [SVHN] Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, Andrew Y. Ng. *Reading Digits in Natural Images with Unsupervised Feature Learning*, NIPS Workshop on Deep Learning and Unsupervised Feature Learning, 2011. Parameters which_format : int Either 1 or 2. Determines which format (format 1: full numbers or format 2: cropped digits) to convert. directory : str Directory in which input files reside. output_directory : str Directory in which to save the converted dataset. output_filename : str, optional Name of the saved dataset. Defaults to 'svhn_format_1.hdf5' or 'svhn_format_2.hdf5', depending on `which_format`. Returns ------- output_paths : tuple of str Single-element tuple containing the path to the converted dataset. """

    if which_format not in (1, 2):
        raise ValueError("SVHN format needs to be either 1 or 2.")
    if not output_filename:
        output_filename = 'svhn_format_{}.hdf5'.format(which_format)
    if which_format == 1:
        return convert_svhn_format_1(
            directory, output_directory, output_filename)
    else:
        return convert_svhn_format_2(
            directory, output_directory, output_filename)