<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_ebounds(hdu_in, hdu=None):
 """ 'Update' the EBOUNDS HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this raises an exception if it doesn not match hdu_in """

    if hdu is None:
        hdu = fits.BinTableHDU(
            data=hdu_in.data, header=hdu_in.header, name=hdu_in.name)
    else:
        for col in ['CHANNEL', 'E_MIN', 'E_MAX']:
            if (hdu.data[col] != hdu_in.data[col]).any():
                raise ValueError("Energy bounds do not match : %s %s" %
                                 (hdu.data[col], hdu_in.data[col]))
    return hdu