<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_hdf5_array(array, h5g, path=None, attrs=None, append=False, overwrite=False, compression='gzip', **kwargs):
 """Write the ``array`` to an `h5py.Dataset` Parameters array : `gwpy.types.Array` the data object to write h5g : `str`, `h5py.Group` a file path to write to, or an `h5py.Group` in which to create a new dataset path : `str`, optional the path inside the group at which to create the new dataset, defaults to ``array.name`` attrs : `dict`, optional extra metadata to write into `h5py.Dataset.attrs`, on top of the default metadata append : `bool`, default: `False` if `True`, write new dataset to existing file, otherwise an exception will be raised if the output file exists (only used if ``f`` is `str`) overwrite : `bool`, default: `False` if `True`, overwrite an existing dataset in an existing file, otherwise an exception will be raised if a dataset exists with the given name (only used if ``f`` is `str`) compression : `str`, `int`, optional compression option to pass to :meth:`h5py.Group.create_dataset` **kwargs other keyword arguments for :meth:`h5py.Group.create_dataset` Returns ------- datasets : `h5py.Dataset` the newly created dataset """

    if path is None:
        path = array.name
    if path is None:
        raise ValueError("Cannot determine HDF5 path for %s, "
                         "please set ``name`` attribute, or pass ``path=`` "
                         "keyword when writing" % type(array).__name__)

    # create dataset
    dset = io_hdf5.create_dataset(h5g, path, overwrite=overwrite,
                                  data=array.value, compression=compression,
                                  **kwargs)

    # write default metadata
    write_array_metadata(dset, array)

    # allow caller to specify their own metadata dict
    if attrs:
        for key in attrs:
            dset.attrs[key] = attrs[key]

    return dset