<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_energy_edges(ene, groups=None):
 """Generate energy bin edges from given energy array. Generate an array of energy edges from given energy array to be used as abcissa error bar limits when no energy uncertainty or energy band is provided. Parameters ene : `astropy.units.Quantity` array instance 1-D array of energies with associated phsyical units. Returns ------- energy_err_lo, energy_error_hi : `astropy.units.Quantity` arrays Arrays of low and high energy edges corresponding to each given energy of the input array. """

    if groups is None or len(ene) != len(groups):
        return _generate_energy_edges_single(ene)
    else:
        eloehi = np.zeros((2, len(ene))) * ene.unit
        for g in np.unique(groups):
            group_edges = _generate_energy_edges_single(ene[groups == g])
            eloehi[:, groups == g] = group_edges
        # hstack throws away units
        return eloehi