code: def unit_key_from_name(name):
    
    result = name
  
    for old, new in six.iteritems(UNIT_KEY_REPLACEMENTS):
      result = result.replace(old, new)
  
    # Collapse redundant underscores and convert to uppercase.
    result = re.sub(r'_+', '_', result.upper())
  
    return result
docs: Return a legal python name for the given name for use as a unit key.