Imported from https://github.com/chang-ml-thu/AWGF