def normalize_units(db):
    'Normalize units in datasets and their exchanges'
    for ds in db:
        if ('unit' in ds):
            ds['unit'] = normalize_units_function(ds['unit'])
        for exc in ds.get('exchanges', []):
            if ('unit' in exc):
                exc['unit'] = normalize_units_function(exc['unit'])
        for param in ds.get('parameters', {}).values():
            if ('unit' in param):
                param['unit'] = normalize_units_function(param['unit'])
    return db
Normalize units in datasets and their exchanges
def normalize_units(db):
    
    for ds in db:
        if ('unit' in ds):
            ds['unit'] = normalize_units_function(ds['unit'])
        for exc in ds.get('exchanges', []):
            if ('unit' in exc):
                exc['unit'] = normalize_units_function(exc['unit'])
        for param in ds.get('parameters', {}).values():
            if ('unit' in param):
                param['unit'] = normalize_units_function(param['unit'])
    return db