import re


def _parse_gpus(s: str) -> str:
    """
    Accept either a comma separated list of numbers 'a,b,c' or a range 'a-c' and return as a string of list of ints.
    """
    # Perhaps unnecessary sanity check?
    s = s.replace(' ', '')
    range_re = re.compile(r'^(\d+)-(\d+)$')
    m = range_re.match(s)
    if m:
        range_ints = list(range(int(m.group(1)), int(m.group(2))+1))
        return ','.join([str(n) for n in range_ints])
    # Otherwise, it's just a comma-separated string already, but we do checks:
    try:
        vals = list(int(n) for n in s.split(','))
    except ValueError:
        print('Oops, wrong GPU number!')
        raise
    return s