reference from https://medium.com/data-science/build-your-own-transformer-from-scratch-using-pytorch-84c850470dcb